Linux, FreeBSD, Juniper, Cisco / Network security articles and troubleshooting guides
https://forum.ivorde.com/

Mysql> how to store select Zulu / UTC timestamp in database
https://forum.ivorde.com/mysql-how-to-store-select-zulu-utc-timestamp-in-database-t1021.html
Page 1 of 1

Author:  debuser [ Fri Dec 16, 2011 5:23 am ]
Post subject:  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".

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/