BST Checking
I thought I'd share my code for BST checking, as I just got round to fixing it!It's pretty simple; work out the date ranges for the year, then check if the date is between them.
function isBST($now) {
$ThisYear = gmdate("Y", $now);
$MarStartDate = ($ThisYear."-03-25");
$OctStartDate = ($ThisYear."-10-25");
$MarEndDate = ($ThisYear."-03-31");
$OctEndDate = ($ThisYear."-10-31");
while ($MarStartDate <= $MarEndDate) {
$day = date("l", strtotime($MarStartDate));
if ($day == "Sunday") {
$BSTStartDate = ($MarStartDate);
}
$MarStartDate++;
}
$BSTStartDate = (date("U", strtotime($BSTStartDate))+(60*60));
while ($OctStartDate <= $OctEndDate) {
$day = date("l", strtotime($OctStartDate));
if ($day == "Sunday") {
$BSTEndDate = ($OctStartDate);
}
$OctStartDate++;
}
$BSTEndDate = (date("U", strtotime($BSTEndDate))+(60*60));
return (($now >= $BSTStartDate) && ($now <= $BSTEndDate));
} Posted at 2003-12-27 09:26:25 by Richard • Link to BST Checking
Comments, trackbacks.
