note 41378 deleted from function.time by aidan

From: Date: Sat, 08 Oct 2005 01:06:25 +0000
Subject: note 41378 deleted from function.time by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-96633@lists.php.net to get a copy of this message
Note Submitter: egarres at veratum.com ---- function timeCaringDayLightSaving($timeZoneOffset) { //if computer timeZoneOffset == 0 (UTC) if (date("Z",time())==0) { $month=date("m",time()); $day=date("d", time()); if ($month>4 && $month<10) $dayLightSaving=1; elseif ($month<4 || $month>10) $dayLightSaving=0; elseif ($month==4) { if ($day>=7) $dayLightSaving=1; elseif(time()>=(strtotime("last Sunday 2:00:00")+$timeZoneOffset)) //if there WAS a Sunday this month 2 am plus offset already, that means we reached the begining of daylight saving already $dayLightSaving=1; else $dayLightSaving=0; } elseif ($month==10) { if ($day<=24) $dayLightSaving=1; elseif(time()<(strtotime("last Sunday 2:00:00")+$timeZoneOffset+(60*60)) && 10==date("m",strtotime("last Sunday 2:00:00")+$timeZoneOffset+(60*60))) //if next sunday is still in this month we are still in daylight saving time $dayLightSaving=1; else $dayLightSaving=0; } return time()+($timeZoneOffset+(60*60*$dayLightSaving)); } else //Use local time return time(); } //-18000 seconds is for EST -05GMT echo date("r", timeCaringDayLightSaving(-18000)); echo date("r", time());

« previous php.notes (#96633) next »