note 83038 added to function.strtotime
| From: | JoH at osu1 dot php dot net | Date: | Wed, 07 May 2008 21:44:42 +0000 |
| Subject: | note 83038 added to function.strtotime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-139152@lists.php.net to get a copy of this message | ||
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)
----
Server IP: 64.71.164.2
Probable Submitter: 70.113.21.57
----
Manual Page -- http://www.php.net/manual/en/function.strtotime.php
Edit -- https://master.php.net/note/edit/83038
Del: integrated -- https://master.php.net/note/delete/83038/integrated
Del: useless -- https://master.php.net/note/delete/83038/useless
Del: bad code -- https://master.php.net/note/delete/83038/bad+code
Del: spam -- https://master.php.net/note/delete/83038/spam
Del: non-english -- https://master.php.net/note/delete/83038/non-english
Del: in docs -- https://master.php.net/note/delete/83038/in+docs
Del: other reasons-- https://master.php.net/note/delete/83038
Reject -- https://master.php.net/note/reject/83038
Search -- https://master.php.net/manage/user-notes.php