note 83038 deleted from function.strtotime by derick

From: Date: Sun, 03 Aug 2008 11:54:13 +0000
Subject: note 83038 deleted from function.strtotime by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-143110@lists.php.net to get a copy of this message
Note Submitter: Jo H ---- British/European summer time starts on the last Sunday in March and ends on the last Sunday in October, at 01:00 GMT. While I could use date("I") to determine whether a date is in summer time or not, my server is on American time and American daylight savings uses different rules. I needed to determine whether a given date falls within the British Summer Time season, and if so convert it back to GMT. This works for me: <?php function BST_finder ($dt) { $BSTstart=strtotime("last Sunday",gmmktime(0,0,0,4,1))+3600; // plus 3600 seconds to make it 1 a.m. $BSTend=strtotime("last Sunday",gmmktime(0,0,0,11,1))+3600; if ($dt>=$BSTstart and $dt<=$BSTend) { $dt=$dt-3600; } return $dt; } $date="2008-10-04 02:45:00"; $dt=strtotime($date); $corrected_date=BST_finder($dt); $pretty_date=date("Y-m-d H:i:s",$corrected_date); // 2008-10-04 01:45:00 ?> (built upon Ian Fieggen's comment below)

« previous php.notes (#143110) next »