note 84531 added to function.time
| From: | MichaelKonecny at osu1 dot php dot net | Date: | Thu, 17 Jul 2008 16:06:15 +0000 |
| Subject: | note 84531 added to function.time | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-141633@lists.php.net to get a copy of this message | ||
It should be noted in the example, that time() + (7*24*60*60) and strtotime("+1 week") do
not always generate the same timestamp. The problem occurs when the daylight saving time changes.
Therefore it's usually better to use strtotime..
Example:
the last time the time changed in the Czech republic was on the 30th March 2008, from 2:00 to 3:00.
Assume it is Wednesday, the 26th March 2008, 23:59.
If you call
<?php echo date("l, jS F Y, H:i",strtotime("+1 week")); ?>
you get Wednesday, 2nd April 2008, 23:59, as you would predict,
although if you try
<?php echo date("l, jS F Y, H:i",time()+(7*24*60*60)); ?>
you get Thursday, 3rd April 2008, 00:59. Here's where things might get a bit confusing, if you
don't expect it!
Suddenly you find the food list for the next week is gone :D !
----
Server IP: 147.32.160.17
Probable Submitter: 62.177.106.40
----
Manual Page -- http://www.php.net/manual/en/function.time.php
Edit -- https://master.php.net/note/edit/84531
Del: integrated -- https://master.php.net/note/delete/84531/integrated
Del: useless -- https://master.php.net/note/delete/84531/useless
Del: bad code -- https://master.php.net/note/delete/84531/bad+code
Del: spam -- https://master.php.net/note/delete/84531/spam
Del: non-english -- https://master.php.net/note/delete/84531/non-english
Del: in docs -- https://master.php.net/note/delete/84531/in+docs
Del: other reasons-- https://master.php.net/note/delete/84531
Reject -- https://master.php.net/note/reject/84531
Search -- https://master.php.net/manage/user-notes.php