Jump to content

UTC - 8 hrs for this script


bluealien

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.