note 45626 added to function.gmmktime

From: Date: Mon, 13 Sep 2004 10:51:03 +0000
Subject: note 45626 added to function.gmmktime
Groups: php.notes 
Request: Send a blank email to php-notes+get-76605@lists.php.net to get a copy of this message
I had a problem with hosting a UK site on a US server, the times didnt match (obviously) and also didnt account for daylight savings time. The daylight savings dates and times of change differ worldwide, so detecting if the server was in dst wouldnt work (see http://webexhibits.org/daylightsaving/). Here is a function for creating a timestamp which can be used by date() to create all the parameters required to display the local time (site not server). I have used GMT time to create the timestamp as there is no offset for UK time (+00). <?php function UKdst_time() { // created by Matthew Waygood (www.waygoodstuff.co.uk) $timestamp = mktime(gmdate("H, i, s, m, d, Y")); // UTC time $this_year=gmdate("Y", $timestamp); // last sunday in march at 1am UTC $last_day_of_march=gmmktime(1,0,0,3,31,$this_year); $last_sunday_of_march=strtotime("-".gmdate("w", $last_day_of_march)." day", $last_day_of_march); // last sunday in october at 1am UTC $last_day_of_october=gmmktime(1,0,0,10,31,$this_year); $last_sunday_of_october=strtotime("-".gmdate("w", $last_day_of_october)." day", $last_day_of_october); if( ($timestamp > $last_sunday_of_march) && ($timestamp < $last_sunday_of_october) ) { $timestamp=$timestamp+3600; // foward one hour } return $timestamp; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.gmmktime.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+45626 Delete -- http://master.php.net/manage/user-notes.php?action=delete+45626&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+45626&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#76605) next »