KevinM1 Posted December 13, 2007 Share Posted December 13, 2007 I have a script that allows members to post upcoming events. The only problem is that, since the script is hosted on one of GoDaddy's shared host servers, the timezone isn't correct. The site shows events on the Eastern side of the US, so the correct timezone should be EST. GoDaddy's server is in MST, so all events are shown taking place an hour earlier than they should, with the wrong timezone abbreviation as well. This has caused people to show up too early for some events, as they're confused about when things are actually taking place. Here's the rub: this script is primarily a 3rd party CMS that I didn't create myself. I have tweaked some of the event registration portion, but not the method with which it saves event dates and times. These events' times are saved in a European format in the database: yyyy-mm-dd hh:mm:ss. When other members register for these events, emails are sent to both the person registering and the site admin. To transform the date into something we Americans are used to, I retrieve the event time from the database and run it through date("m-d-Y h:i:s T", $eventTimestamp). The problem, like I said before, is that since GoDaddy's server is in MST, that's what the 'T' flag in the date() function displays. Is there a simple way for me to set the timezone as +2 for it to display EST rather than MST? I know I could always just remove the 'T' flag and append 'EST' to the string, but I'm curious to see if there's a way to do it within the function itself. Quote Link to comment https://forums.phpfreaks.com/topic/81533-solved-fun-with-date-and-timezones/ Share on other sites More sharing options...
Crew-Portal Posted December 13, 2007 Share Posted December 13, 2007 Use this setting for a global wide time date_default_timezone_set(); Or you can do what PHPbb does and allow people to create thier own timezones by modifying the date syntax and allowing them to save tier time info to mysql and all the site data calls from the SQL Query. Quote Link to comment https://forums.phpfreaks.com/topic/81533-solved-fun-with-date-and-timezones/#findComment-413979 Share on other sites More sharing options...
KevinM1 Posted December 13, 2007 Author Share Posted December 13, 2007 Use this setting for a global wide time date_default_timezone_set(); Or you can do what PHPbb does and allow people to create thier own timezones by modifying the date syntax and allowing them to save tier time info to mysql and all the site data calls from the SQL Query. Great, thanks! I just need to double-check that the hosting plan is using PHP5 by default. Quote Link to comment https://forums.phpfreaks.com/topic/81533-solved-fun-with-date-and-timezones/#findComment-413989 Share on other sites More sharing options...
revraz Posted December 13, 2007 Share Posted December 13, 2007 I have a offset field in my users's profiles, to add/subtract for their timezone. I tried the default.time zone setting in PHP 5 and it didn't do what I wanted. Quote Link to comment https://forums.phpfreaks.com/topic/81533-solved-fun-with-date-and-timezones/#findComment-413995 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.