note 79256 deleted from function.date by felipe
| From: | felipe@php.net | Date: | Sun, 09 Dec 2007 13:17:10 +0000 |
| Subject: | note 79256 deleted from function.date by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-132980@lists.php.net to get a copy of this message | ||
Note Submitter: ike at concept47 dot com
----
if you try to increment your time stamp using
<?php $oneday = 24*60*60//(seconds in 24 hours)?>
you will run into trouble with the dates Nov 4th/5th 2007, where date() reports them as the same day
example:
<?php
echo date('m-d-Y', 1194152400); //reports as 11-04-2007
echo date ('m-d-Y', 1194238800); //reports as 11-04-2007 .. should be 11-05-2007
echo date ('m-d-Y', 1194242400); //reports correctly as 11-05-2007 ... this uses 25*60*60
?>
You will notice that the last entry works .... that is using
<?php $oneday = 25*60*60 //(25 hrs instead of 24)?>
However for iterations over large ranges of time ... subtle errors will creep in ... it is better to
use the native php function strtotime to calculate it for you
example:
<?php
$current_timestamp = strtotime("+1 day", $current_timestamp);
?>