note 100816 added to function.date

From: Date: Tue, 09 Nov 2010 04:36:20 +0000
Subject: note 100816 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-173870@lists.php.net to get a copy of this message
Modifying "d basin"'s note about excel-formatted dates, his note fails under PHP 4. (Sadly, still commonly used!) Instead, you can use a call like this: function ExceldateToDate($excel_date) { if (!is_numeric($excel_date)) return -1; return date('m/d/Y', strtotime('12/30/1899 + $excel_date days ')); } For whatever reason, the second subtraction operation within the string "- 2 days" confuses strtotime in PHP4.x, but taking this out of the beginning of the equation works fine. ---- Server IP: 64.71.164.2 Probable Submitter: 67.161.188.99 ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- https://master.php.net/note/edit/100816 Del: integrated -- https://master.php.net/note/delete/100816/integrated Del: useless -- https://master.php.net/note/delete/100816/useless Del: bad code -- https://master.php.net/note/delete/100816/bad+code Del: spam -- https://master.php.net/note/delete/100816/spam Del: non-english -- https://master.php.net/note/delete/100816/non-english Del: in docs -- https://master.php.net/note/delete/100816/in+docs Del: other reasons-- https://master.php.net/note/delete/100816 Reject -- https://master.php.net/note/reject/100816 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#173870) next »