datetime - How do you change the timezone in PHP for an existing timestamp? -
the code date , time function:
function date_and_time($format,$timestamp) { $date_and_time = date($format,$timestamp); return $date_and_time; }
and code display it:
<?php echo date_and_time("ds f y", strtotime($profile[last_activity_date_and_time])); ?>
the value of $profile[last_activity_date_and_time] 2010-01-18 14:34:04
when displayed shows 18th january 2010 - 02:34pm
but, there way change timezone displayed in?
not sure if you're looking for, try datetime
date_default_timezone_set('europe/london'); $datetime = new datetime(); $datetime->settimestamp($yourtimestamp); echo $datetime->gettimezone()->getname(); echo $datetime->format(date_atom); $la_time = new datetimezone('america/los_angeles'); $datetime->settimezone($la_time); echo $datetime->gettimezone()->getname(); echo $datetime->format(date_atom);
Comments
Post a Comment