note 74583 deleted from ref.datetime by felipe

From: Date: Mon, 10 Dec 2007 17:49:25 +0000
Subject: note 74583 deleted from ref.datetime by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-133213@lists.php.net to get a copy of this message
Note Submitter: wes9999 at myfastmail dot com ---- Regarding the dateDiff function submitted by andreencinas at yahoo dot com dot br: http://us3.php.net/manual/en/ref.datetime.php#57251 A daylight savings time problem was discovered when doing the datediff (in days) on 4/1/2005 and 5/1/2005, for example. I expected to get 30 days, but instead I got 29 days. This was due to the fact that dateDiff uses strtotime on each of these dates, then subtracts them, then divides by 86400 to get days. The resulting difference is 29.958333333333, and then the function takes the floor of this number, producing 29. The reason for this is that an hour of time is lost during the switch to DST. A quick solution is to replace floor() with round(), but I'm open to other solutions.

« previous php.notes (#133213) next »