Jump to content

Determining Daylight Savings Time


elmas156

Recommended Posts

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

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.