Artem
Artem

Reputation: 559

How to insert YYYY-MM-DDThh:mm:ss±hh:mm date in mysql with timezone?

I try to insert this date "2014-06-18T12:32:56.575+10:00" in timestamp field. But is saved "2014-06-18 12:32:56" without timezone. How can I convert date to UTC or other timezone?

Upvotes: 1

Views: 756

Answers (1)

seahawk
seahawk

Reputation: 1912

Use datetime datatype instead of timestamp.

As per MySQL documentation:

MySQL converts TIMESTAMP values from the current time zone to UTC for storage, and back from UTC to the current time zone for retrieval. This does not occur for other types such as DATETIME

If your are already using datetime then set default timezone of MySQL or set timezone per connection.

Upvotes: 2

Related Questions