elmas156 Posted November 29, 2010 Share Posted November 29, 2010 I'm using a time stamp where I'm getting the date and time from the database server rather than using a unix time stamp. Because I'm in a different time zone as the server, my time was always off by 1 hour. I fixed that problem by writing some code to adjust the hour of the time and the date depending on what time it was. It was working fine until a few weeks ago when I had to adjust my clock for daylight savings time... now the time is off by 2 hours because of that. Well, I fixed that and now it's working fine again. My question is does anyone know of a way to automatically determine whether or not I should be in daylight savings time or not so I can just use an if/else statement to keep the time adjusted properly rather than having to do it manually every time the time changes? Basically, I would like to do it something like the following: <?php if ($daylightsavings = "y") { (adjust time/date for 1 hour difference); } else { (adjust time/date for 2 hour difference); } ?> Anyone have any ideas? Link to comment https://forums.phpfreaks.com/topic/220163-determining-daylight-savings-time/ Share on other sites More sharing options...
jdavidbakr Posted November 29, 2010 Share Posted November 29, 2010 Try date_default_timezone_set() to change your script into your own time zone. Great tutorial on working with dates and times here: http://www.phpfreaks.com/tutorial/working-with-dates-in-php Link to comment https://forums.phpfreaks.com/topic/220163-determining-daylight-savings-time/#findComment-1141043 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.