starphp Posted May 6, 2009 Share Posted May 6, 2009 Hello, I have stored date & time in the MySql database using the data type (DATETIME). I wish to display the date time in EST time zone. How can I achieve this ? I have tried to change the TimeZone using the php function: date_default_timezone_set("EST"); But it doesn't work. I have modified the date format by using the code: date("M j", strtotime($data['received_time']) )." at ".date("g:ia", strtotime($data['received_time']) ) to display the time as May 6 at 10:10am Is this correct ? Actually I am trying to display time in User's Time Zone. If no time zone is present, then it will be displayed in EST format. And for that I stored date & time in MySql and did the steps. Also, is it possible to find the TimeZone of user during registration process without a TimeZone selection menu ? Any suggestions would be great. Thank You. Link to comment https://forums.phpfreaks.com/topic/157059-date-time-with-time-zone/ Share on other sites More sharing options...
The Little Guy Posted May 8, 2009 Share Posted May 8, 2009 ini_set('date.timezone', 'US/Eastern'); echo date("M j \a\t g:ia", strtotime($data['received_time'])); List of timezones: http://us3.php.net/manual/en/timezones.php Link to comment https://forums.phpfreaks.com/topic/157059-date-time-with-time-zone/#findComment-829223 Share on other sites More sharing options...
starphp Posted May 11, 2009 Author Share Posted May 11, 2009 Your code works. Thank you Mr Little Guy. Link to comment https://forums.phpfreaks.com/topic/157059-date-time-with-time-zone/#findComment-831425 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.