4

I'm confused about timezone differences when converting a MySQL datetime to Unix timestamp. It appears to me that MySQL datetimes (2011-02-07 09:45:00) are in the server's local timezone. I want to convert this datetime into a Unix timestamp, which is always in the GMT timezone. To do this conversion, PHP passes the datetime into strtotime. The datetime string contains no timezone, so will strtotime assume the argument is local timezone or GMT?

2 Answers 2

5

The strtotime function will assume the datetime is in the server's local timezone.

Sign up to request clarification or add additional context in comments.

Comments

0

Why not use MySQL's UNIX_TIMESTAMP() function?

1 Comment

Because the project running on the server, and the sever are in two different timezones. Referring the servers timezone will give wrong data to the site user. I've used php's date_default_timezone_set('XXX'); to change the default timezone for the site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.