note 79256 added to function.date

From: Date: Sat, 17 Nov 2007 18:33:43 +0000
Subject: note 79256 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-132374@lists.php.net to get a copy of this message
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); ?> ---- Server IP: 64.71.164.2 Probable Submitter: 70.124.48.24 ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- https://master.php.net/note/edit/79256 Del: integrated -- https://master.php.net/note/delete/79256/integrated Del: useless -- https://master.php.net/note/delete/79256/useless Del: bad code -- https://master.php.net/note/delete/79256/bad+code Del: spam -- https://master.php.net/note/delete/79256/spam Del: non-english -- https://master.php.net/note/delete/79256/non-english Del: in docs -- https://master.php.net/note/delete/79256/in+docs Del: other reasons-- https://master.php.net/note/delete/79256 Reject -- https://master.php.net/note/reject/79256 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#132374) next »