I have a MySQL field that is DATETIME
... I have a PHP page that generates a query that will add some data in a table which includes teh DATETIME
field.
The question is, how can I add the DATETIME
from PHP to MySQL?
I want to add the time in GMT/UTC 24H format
$current_time = date ('Y-m-d h:m');
mysql> create table t1 (id int, blah datetime);
Query OK, 0 rows affected (0.01 sec)
mysql> insert into t1 values (1, '2008-01-01 12:32');
Query OK, 1 row affected (0.00 sec)
mysql> select * from t1;
+------+---------------------+
| id | blah |
+------+---------------------+
| 1 | 2008-01-01 12:32:00 |
+------+---------------------+
1 row in set (0.00 sec)
$time = date ('Y-m-d h:m');
Then insert $time into your mysql table
see http://php.net/manual/en/class.datetime.php for more info