PHP Date/Time Check with BST
function BSTCheck() {
$ThisYear = (date("Y"));
$MarStartDate = ($ThisYear."-03-25");
$OctStartDate = ($ThisYear."-10-25");
$MarEndDate = ($ThisYear."-03-31");
$OctEndDate = ($ThisYear."-10-31");
//work out the Unix timestamp for 1:00am GMT on the last Sunday of March, when BST starts
while ($MarStartDate <= $MarEndDate) {
$day = date("l", strtotime($MarStartDate));
if ($day == "Sunday")
$BSTStartDate = ($MarStartDate);
$MarStartDate++;
}
$BSTStartDate = (date("U", strtotime($BSTStartDate))+(60*60));
//work out the Unix timestamp for 1:00am GMT on the last Sunday of October, when BST ends
while ($OctStartDate <= $OctEndDate) {
$day = date("l", strtotime($OctStartDate));
if ($day == "Sunday")
$BSTEndDate = ($OctStartDate);
$OctStartDate++;
}
$BSTEndDate = (date("U", strtotime($BSTEndDate))+(60*60));
//Check to see if we are now in BST
$now = mktime();
return (($now >= $BSTStartDate) && ($now <= $BSTEndDate)) ? TRUE : FALSE;
}
$DST = (BSTCheck()) ? 3600 : 0;
$time = gmdate("H:i", time() + $DST);
$night = ((date("H")>=17) OR (date("H")<5)) ? TRUE : FALSE;
What I'm Doing...
- Am I getting old, is it my stinking cold, or are captcha's getting harder? 1 day ago
- Still feeling pretty rotten but determined to get at least a couple of things off this list today! 1 day ago
- Not really looked properly at EC2 in a long time, but all @lgladdy 's tweets about it are pushing me in that direction again, any good tips? 1 day ago
- Android why can't I create a repition of a calendar event every other week? I can do weekly, every xth of the month but not every other! 2 days ago
- Get a private beta invite for Connect.Me. It's your reputation card for the social web http://t.co/ZWV66HMM 2 days ago
- More updates...


