what is the correct format of a column for store UTC date time

173 views Asked by At

I have a column name serverUTC. I want to store UTC date time.I set the type is DATETIME and not null default CURRENT_TIMESTAMP. Please suggest me how I can store UTC date time

1

There are 1 answers

0
Adam On

MySQL store date in UTC but show (select) in your time zone. And if you insert date then convert to UTC before store.

You can use function UTC_TIMESTAMP() when selecting data or set/change default_time_zone.

More info and examples:

https://dba.stackexchange.com/questions/20217/mysql-set-utc-time-as-default-timestamp

https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.htm