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
Share on other sites

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.