Best method for PHP Timezones

liedFiviado

New Member
Question 1)
Assuming a user has a timezone setting saved as 'America/New_York' in my application, would I just use this on a page where I need to show the correct time with timezone offset and daylight savings applied\[code\]<?php$time_zone = 'America/New_York';date_default_timezone_set($time_zone);echo date('D,F j, Y, h:i:s A');?>\[/code\]OR should I use something more like this approachWhen I query my data I use the following PHP script\[code\]<?PHPwhile($row = mysql_fetch_array($registration)){ $dt_obj = new DateTime($row['message_sent_timestamp']." UTC");$dt_obj->setTimezone(new DateTimeZone('America/New_York'));echo $formatted_date_long=date_format($dt_obj, 'Y-m-d H:i:s'); }?>\[/code\]
 
Back
Top