Store php datetime in mysql database
mysql, php
Solution
Don't save it as the Unix Timestamp (which `strtotime()` outputs), but as "2012-12-02 13:00" into the DATETIME column.
Problem
I can't believe I can't do this, but I want to be able to store the current date and time from php in to a mysql table. The column in the table is type datetime. I've tried this ``` $current_date = date("Y-m-d"); $my_date = strtotime($current_date); INSERT INTO my_table (date_time) VALUES ('$my_date') ``` but my timestamp comes up as 0000-00-00 00:00:00 This must be so easy to do but I just can't get it working! I want to use the timestamp from php rather than using the mysql now() function