php datetime to mysql |
[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
[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"); |
Welcome Guest, Not a member yet? Register Sign In |