Jump to content

[SOLVED] Fun with date() and timezones


KevinM1

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.