![]() |
php datetime to mysql - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: php datetime to mysql (/showthread.php?tid=34488) |
php datetime to mysql - El Forum - 10-01-2010 [eluser]Corbee[/eluser] Hi, I'm trying to insert this Code: $inceptiondate = date("Y-m-d 12:00:00"); to the database, the Y-m-d does make it to database, but the 12:00pm doesn't. Whenever it reaches the database, it becomes 00:00:00 Where did I got wrong? Thanks php datetime to mysql - El Forum - 10-01-2010 [eluser]LeonardoGaiero[/eluser] Sounds like to me you're trying to give MySQL a malformed value. See the manual: http://php.net/manual/en/function.date.php The function accepts identifiers for the various date/time components, and you're trying to pass numeric values mixed in, which is wrong. To achieve what you're trying to do, you should rather do something like this (untested): Code: $inceptiondate = date("Y-m-d") . " 12:00:00"; or better yet, generate the whole date field automatically: Code: $inceptiondate = date("Y-m-d H:i:s"); |