note 22495 added to function.date
| From: | flinnatactiveintradotnet@php.net | Date: | Thu, 20 Jun 2002 09:09:42 +0000 |
| Subject: | note 22495 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-32033@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";
}
--
http://www.php.net/manual/en/function.date.php
http://master.php.net/manage/user-notes.php?action=edit+22495
http://master.php.net/manage/user-notes.php?action=delete+22495
http://master.php.net/manage/user-notes.php?action=reject+22495