bluealien Posted December 15, 2009 Share Posted December 15, 2009 Can someone please help me rewrite this to handle UTC - 8 hrs for PST.. <td class="'.(date("Ymd", mktime (0,0,0,$c_month,$i,$c_year))==date("Ymd")?'current-day':'day-with-date').$no_events_class.'"> Thanks for the help Quote Link to comment https://forums.phpfreaks.com/topic/185280-utc-8-hrs-for-this-script/ Share on other sites More sharing options...
bluealien Posted December 15, 2009 Author Share Posted December 15, 2009 sorry for got to mention my servers is 8 hrs a head of me ... so I need to set this - 8 hrs to have it display correctly form my local date & time. thanks again Quote Link to comment https://forums.phpfreaks.com/topic/185280-utc-8-hrs-for-this-script/#findComment-978064 Share on other sites More sharing options...
premiso Posted December 15, 2009 Share Posted December 15, 2009 As long as you are working with PHP5+ : I would suggest using: date_timezone_set Quote Link to comment https://forums.phpfreaks.com/topic/185280-utc-8-hrs-for-this-script/#findComment-978082 Share on other sites More sharing options...
bluealien Posted December 16, 2009 Author Share Posted December 16, 2009 Thanks for the suggestion, however I dont know how to re-write this to use your suggestion ... I am on php5 .. thanks Quote Link to comment https://forums.phpfreaks.com/topic/185280-utc-8-hrs-for-this-script/#findComment-978302 Share on other sites More sharing options...
premiso Posted December 16, 2009 Share Posted December 16, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/185280-utc-8-hrs-for-this-script/#findComment-978620 Share on other sites More sharing options...
bluealien Posted December 17, 2009 Author Share Posted December 17, 2009 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)); Quote Link to comment https://forums.phpfreaks.com/topic/185280-utc-8-hrs-for-this-script/#findComment-979536 Share on other sites More sharing options...
premiso Posted December 17, 2009 Share Posted December 17, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/185280-utc-8-hrs-for-this-script/#findComment-979541 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.