How do I convert a date/time string (e.g. 2011-01-01 15:00:00) that is UTC to any given timezone php supports, such as America/New_York, or Europe/San_Marino.
PHP's DateTime object is pretty flexible.
DateTime
$UTC = new DateTimeZone("UTC"); $newTZ = new DateTimeZone("America/New_York"); $date = new DateTime( "2011-01-01 15:00:00", $UTC ); $date->setTimezone( $newTZ ); echo $date->format('Y-m-d H:i:s');
2.1m questions
2.1m answers
60 comments
57.0k users