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

Popular posts from this blog

unicode - Are email addresses allowed to contain non-alphanumeric characters? -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -