note 74583 added to ref.datetime

From: Date: Wed, 18 Apr 2007 15:33:06 +0000
Subject: note 74583 added to ref.datetime
Groups: php.notes 
Request: Send a blank email to php-notes+get-125547@lists.php.net to get a copy of this message
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. ---- Server IP: 216.194.113.175 Probable Submitter: 69.210.197.187 (proxied: unknown) ---- Manual Page -- http://www.php.net/manual/en/ref.datetime.php Edit -- https://master.php.net/note/edit/74583 Del: integrated -- https://master.php.net/note/delete/74583/integrated Del: useless -- https://master.php.net/note/delete/74583/useless Del: bad code -- https://master.php.net/note/delete/74583/bad+code Del: spam -- https://master.php.net/note/delete/74583/spam Del: non-english -- https://master.php.net/note/delete/74583/non-english Del: in docs -- https://master.php.net/note/delete/74583/in+docs Del: other reasons-- https://master.php.net/note/delete/74583 Reject -- https://master.php.net/note/reject/74583 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#125547) next »