note 36939 added to function.mktime

From: Date: Tue, 28 Oct 2003 04:59:19 +0000
Subject: note 36939 added to function.mktime
Groups: php.notes 
Request: Send a blank email to php-notes+get-59398@lists.php.net to get a copy of this message
>$i = mktime(0,0,0,10,22,2003) in a loop adding 86400 to it will >produce incorrect date('d',$i) results. Ik getting 2 times the 26 th of >october >this way. I think because incorrect rounding the results. >use mktime(12,0,0,10,22,2003) instead. Problem is daylightsavings time. I use function like: function nextdaysec($time, $numdays = 1) { // takes unix timestamp and returns // next days timestamp (+ 86400 sec all otherday but daylightsavings) $atoms = explode(".",date("H.i.s.n.j.Y", $time)); $result=(mktime($atoms[0], $atoms[1], $atoms[2], $atoms[3], ($atoms[4]+$numdays), $atoms[5])); return $result; } ... to increment my timestamps. Maybe it could be lighter, but at least it works correctly. ---- Manual Page -- http://www.php.net/manual/en/function.mktime.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+36939 Delete -- http://master.php.net/manage/user-notes.php?action=delete+36939&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+36939&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#59398) next »