note 100816 deleted from function.date by danbrown
| From: | danbrown@php.net | Date: | Tue, 09 Nov 2010 04:41:21 +0000 |
| Subject: | note 100816 deleted from function.date by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-173871@lists.php.net to get a copy of this message | ||
Note Submitter: bsmith at benjamindsmith dot com
----
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.