note 86275 added to function.date

From: Date: Fri, 10 Oct 2008 13:08:54 +0000
Subject: note 86275 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-145242@lists.php.net to get a copy of this message
Hi ! I've had a specific need to find out if a day is the day when a country switch to winter/spring times , aka loosing one hour or getting one hour compared to the real time .. This works in europe , but i don't know about other regulations or countries , so be warned. The switch to "spring time" is always on the last saturday of march. The switch to winter time is always last saturday of october. Hope it helps ! use it like this : if(checkSwitchToWinterTime('20081025'){ echo 'today we switch to winter time' ; } function checkSwitchToWinterTime($day){ //day is yyyymmdd $y =substr($day,0,4); $m = substr($day,4,2); $d = substr($day,6,2); // if it is a saturday of october, check if it's the last one if(date("D-m", mktime(0, 0, 0, $m, $d, $y))=="Sat-10"){ ; if((date("m", mktime(0, 0, 0, $m, $d, $y))) != (date("m", mktime(0, 0, 0, $m, $d+7, $y)))) { return true; } return; } return; } function checkSwitchToSpringTime($day){ //day is yyyymmdd $y =substr($day,0,4); $m = substr($day,4,2); $d = substr($day,6,2); // if it is a saturday of march, check if it's the last one if(date("D-m", mktime(0, 0, 0, $m, $d, $y))=="Sat-03"){ ; if((date("m", mktime(0, 0, 0, $m, $d, $y))) != (date("m", mktime(0, 0, 0, $m, $d+7, $y)))) { return true; } return; } return; } ---- Server IP: 213.246.51.26 Probable Submitter: 195.248.4.144 ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- https://master.php.net/note/edit/86275 Del: integrated -- https://master.php.net/note/delete/86275/integrated Del: useless -- https://master.php.net/note/delete/86275/useless Del: bad code -- https://master.php.net/note/delete/86275/bad+code Del: spam -- https://master.php.net/note/delete/86275/spam Del: non-english -- https://master.php.net/note/delete/86275/non-english Del: in docs -- https://master.php.net/note/delete/86275/in+docs Del: other reasons-- https://master.php.net/note/delete/86275 Reject -- https://master.php.net/note/reject/86275 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#145242) next »