Mysql> how to store select Zulu / UTC timestamp in database
To obtain/store the current time in mysql, function "NOW()" needs to be used. But this takes into consideration the timezone set on the server.
To store the UTC time, in the same format, "UTC_TIMESTAMP()" function can be used:
Code:
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2011-12-16 10:19:33 |
+---------------------+
1 row in set (0.00 sec)
mysql> select UTC_TIMESTAMP();
+---------------------+
| UTC_TIMESTAMP() |
+---------------------+
| 2011-12-16 09:19:36 |
+---------------------+
1 row in set (0.05 sec)
P.S.: The column type for NOW() and UTC_TIMESTAMP() in mysql is "datetime".