Jo Smo Jo Smo - 1 year ago 134
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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download