note 99515 deleted from function.date by tularis
| From: | tularis@php.net | Date: | Thu, 09 Feb 2012 20:54:28 +0000 |
| Subject: | note 99515 deleted from function.date by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-185975@lists.php.net to get a copy of this message | ||
Note Submitter: peter_silvester at yahoo dot com
----
Function to return whether or not a given date falls within British Summer Time:
<?php
function is_bst($date) {
$Year = date("Y", $date);
$MarLast = $Year."-03-31";
$OctLast = $Year."-10-31";
//Find the last Sunday in March
if (date("w", strtotime($MarLast)) == 0) //Sunday
{
$LastMarSun = strtotime($MarLast);
} else {
$LastMarSun = strtotime($MarLast." last sunday");
}
//Find the last Sunday in October
if (date("w", strtotime($OctLast)) == 0) //Sunday
{
$LastOctSun = strtotime($OctLast);
} else {
$LastOctSun = strtotime($OctLast." last sunday");
}
$BSTStart = strtotime(date("Y-m-d", $LastMarSun)." 01:00:00");
$BSTEnd = strtotime(date("Y-m-d", $LastOctSun)." 01:00:00");
return (($date >= $BSTStart) && ($date <= $BSTEnd));
}
?>