note 97025 added to function.strtotime
| From: | clarkDONTSPAMMEwise at gmail dot com | Date: | Mon, 29 Mar 2010 05:31:11 +0000 |
| Subject: | note 97025 added to function.strtotime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-167479@lists.php.net to get a copy of this message | ||
Always use the format strtotime("+1 day") when adding/subtracting units of time rather
than manually adding 24*60*60 seconds to a timestamp, for example, as this format works as desired
with Daylight Saving Time changes. If your timezone adheres to Daylight Saving Time, a situation
like the following may apply to you:
<?php
date_default_timezone_set('America/Chicago');
// Don't do this:
$today = '2009-11-01';
$tomorrow = strtotime($today) + 24*3600;
print date('Y-m-d', $tomorrow);
// Output: 2009-11-01
// Do this instead:
$today = '2009-11-01';
$tomorrow = strtotime('+1 day', strtotime($today));
print date('Y-m-d', $tomorrow);
// Output: 2009-11-02
----
Server IP: 64.71.164.2
Probable Submitter: 24.107.148.0
----
Manual Page -- http://www.php.net/manual/en/function.strtotime.php
Edit -- https://master.php.net/note/edit/97025
Del: integrated -- https://master.php.net/note/delete/97025/integrated
Del: useless -- https://master.php.net/note/delete/97025/useless
Del: bad code -- https://master.php.net/note/delete/97025/bad+code
Del: spam -- https://master.php.net/note/delete/97025/spam
Del: non-english -- https://master.php.net/note/delete/97025/non-english
Del: in docs -- https://master.php.net/note/delete/97025/in+docs
Del: other reasons-- https://master.php.net/note/delete/97025
Reject -- https://master.php.net/note/reject/97025
Search -- https://master.php.net/manage/user-notes.php