note 22495 deleted from function.date by sniper

From: Date: Sat, 18 Jan 2003 01:34:02 +0000
Subject: note 22495 deleted from function.date by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-42319@lists.php.net to get a copy of this message
The normal function for checking daylight saving time doesn't work if you don't take part in it. This will tell you if the the US is in DST. function isDST() { //First Sunday in April for($c = 1;$c < 8; $c++) { if (date ("l", mktime(0,0,0,4,$c,date("Y"))) == "Sunday") { $dstStartDate = date ("U", mktime(2,0,0,4,$c,date("Y"))); } } //Last Sunday in October for($c = date("t");$c > (date("t") - 7); $c--) { if (date ("l", mktime(0,0,0,10,$c,date("Y"))) == "Sunday") { $dstEndDate = date ("U", mktime(2,0,0,10,$c,date("Y"))); } } if (date("U") > $dstStartDate && date("U") < $dstEndDate) { return true; } else { return false; } } if (isDST() == true) { echo "Daylight Saving Time"; } else { echo "Standard Time"; }

« previous php.notes (#42319) next »