Jo Smo Jo Smo - 10 months ago 74
PHP Question

How to convert a datetime string to UTC string?

I have a datetime string like this:

`2012-09-03 22:00 Central USA Time`.

and i want to convert it to the UTC time zone.

Answer Source

Use gmdate() and strtotime() :

echo gmdate('Y-m-d H:i', strtotime('2012-09-03 22:00'));

Instead of Central USA Time, use the supported timezones :

The date_default_timezone_get() function will always give you the right timezone