php convert datetime to UTC

Jeremey picture Jeremey · Jan 19, 2010 · Viewed 236k times · Source

I am in need of an easy way to convert a date time stamp to UTC (from whatever timezone the server is in) HOPEFULLY without using any libraries.

Answer

poke picture poke · Jan 19, 2010

Use strtotime to generate a timestamp from the given string (interpreted as local time) and use gmdate to get it as a formatted UTC date back.

Example

As requested, here’s a simple example:

echo gmdate('d.m.Y H:i', strtotime('2012-06-28 23:55'));