note 94347 added to function.date

From: Date: Thu, 29 Oct 2009 17:27:13 +0000
Subject: note 94347 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-162258@lists.php.net to get a copy of this message
Hallo, I thing that Corey's note (http://cz2.php.net/manual/en/function.date.php#69221) have a mistake. Please correct me if it is not true. If date("g") returns 1 as hour and DST is set (in that example), than intval(date("g")) - 1 returns 0 and it is not good because than you have 0..12=13 hours per half day in result with this method of DST correction :) I thing that correct algorithm for formating timestamp with DST is: function dstdate($format,$timestamp=0) { if ($timestamp==0) $timestamp=time(); return date($format,date("I",$timestamp) ? $timestamp : $timestamp-3600); } Comment: If DST is *not* set (==0) in given $timestamp, than we subtract one hour from source timestamp and then we format timestamp to string. We assume that PHP date function returns time with no DST correction, so we correct it before it is processed by PHP date. If DST is *not* set (winter time) and there is 1:00 we have 12:00 as result if we have hours formated by "g" not 0:00 as in Corey's code. ---- Server IP: 147.32.160.17 Probable Submitter: 212.71.183.40 ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- https://master.php.net/note/edit/94347 Del: integrated -- https://master.php.net/note/delete/94347/integrated Del: useless -- https://master.php.net/note/delete/94347/useless Del: bad code -- https://master.php.net/note/delete/94347/bad+code Del: spam -- https://master.php.net/note/delete/94347/spam Del: non-english -- https://master.php.net/note/delete/94347/non-english Del: in docs -- https://master.php.net/note/delete/94347/in+docs Del: other reasons-- https://master.php.net/note/delete/94347 Reject -- https://master.php.net/note/reject/94347 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#162258) next »