Jump to content

Recommended Posts

After looking through google, here is one way to do. Store the users timezone in the database (have them select etc etc). You can then use putenv to change the timezone as follows:

 

ini_set("date.timezone", "US/Mountain");
echo "Original Time(Mountain): ". date("H:i:s")."\n<br />";
ini_set("date.timezone", "US/Eastern");
echo "New Time (Eastern): ". date("H:i:s")."\n";
die();
?>

 

Using that method, you would just need to put that in one of your includes that goes through all pages, and you can pull that value from session (IE store that value in session when the user logs in). Then just use ini_set as shown above to change the timezone. I hope that makes sense, if not let me know.

 

For a list of valid times: http://www.php.net/manual/en/timezones.php

After looking through google, here is one way to do. Store the users timezone in the database (have them select etc etc). You can then use putenv to change the timezone as follows:

 

ini_set("date.timezone", "US/Mountain");
echo "Original Time(Mountain): ". date("H:i:s")."\n<br />";
ini_set("date.timezone", "US/Eastern");
echo "New Time (Eastern): ". date("H:i:s")."\n";
die();
?>

 

Using that method, you would just need to put that in one of your includes that goes through all pages, and you can pull that value from session (IE store that value in session when the user logs in). Then just use ini_set as shown above to change the timezone. I hope that makes sense, if not let me know.

 

For a list of valid times: http://www.php.net/manual/en/timezones.php

 

Thanks for the suggestion but this is to complicated ... the user never logs in ... its just to view a calender based on today, the problem is it was written to call server time and not to offset based on local time of the events when this is setup ... just wanted to modify .date() call to offset - 8 PST

 

gmdate("F j, Y", time()-(28800));

 

Well using the method I provided you can just set the timezone to be that PST time, what would be the problem with doing that?

 

Simply do this at the top of your script:

ini_set("date.timezone", "US/Pacific");

 

That will set all times for that script to be pacific time. Is that not what you want?

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.