gple Posted December 28, 2010 Share Posted December 28, 2010 $date=date("Y-m-d H:i:s"); This is returning me the GMT time instead of EST. I get 15:26:08 as the time instead of 10:26:08. How can I get around this? Link to comment https://forums.phpfreaks.com/topic/222827-date-function/ Share on other sites More sharing options...
johnny86 Posted December 28, 2010 Share Posted December 28, 2010 <?php $date = new DateTime('now', new DateTimeZone('Your/Timezone')); echo $date->format('Y-m-d H:i:s') . "\n"; // Example $date = new DateTime('now', new DateTimeZone('Europe/Helsinki')); echo $date->format('Y-m-d H:i:s') . "\n"; // 2010-12-28 17:38:45 ?> Link to comment https://forums.phpfreaks.com/topic/222827-date-function/#findComment-1152163 Share on other sites More sharing options...
the182guy Posted December 28, 2010 Share Posted December 28, 2010 To do it script wide so that all your date() calls will be in the specified timezone use: date_default_timezone_set('EST'); Link to comment https://forums.phpfreaks.com/topic/222827-date-function/#findComment-1152167 Share on other sites More sharing options...
gple Posted December 28, 2010 Author Share Posted December 28, 2010 so what would i put in for new york time? DateTimeZone('America/New York')? Link to comment https://forums.phpfreaks.com/topic/222827-date-function/#findComment-1152171 Share on other sites More sharing options...
johnny86 Posted December 28, 2010 Share Posted December 28, 2010 http://fi.php.net/manual/en/timezones.america.php America/New_York Link to comment https://forums.phpfreaks.com/topic/222827-date-function/#findComment-1152176 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.