Jun
3
3
PHP: Change UTC time to local time
Did you know that you can quickly change UTC time stamps to Local time by doing the following:
//make sure your time is set
date_default_timezone_set('America/New_York');
$datetime = '2004-02-12T15:19:21+00:00';
//convert the given datetime string to time
$newDatetime = strtotime($datetime);
//re-contruct to format
$newDatetime = date('Y-m-d H:i:s', newDatetime);
It’s so obvious, but I only wished, I knew this before trying all sort of crazy stuff.
1 Comment to “PHP: Change UTC time to local time”
Leave a comment
Recent Posts
Tags
add-on
Ajax
alerts
api
application
Apps
border-radius
charts
CMS
CSS
CSS3
CURL
debug
dojo
Facebook
firebug
firefox
getsimple
google
iPhone
jAlert
JavaScript
jQuery
Linux
log
messages
optimization
PHP
plug-in
programming
prototype
Resources
session
squareit
tips
tweetmeme
Ubuntu
wildfire
XML
yahoo
Zend
Zend Framework
Zend Studio
Zend_Cache
Zend_Feed
[...] Originally posted here: PHP Blog on: PHP: Change UTC time to local time [...]