|
Posted by Ewoud Dronkert on 12/08/05 23:09
Sjoerd wrote:
> number of days since 1-1-1900
Of course! I missed a decimal, and thought: "Hmm what could it be, number
of days since 1995 somewhere?!"
Unfortunately mktime(0, 0, 0, 1, 38694, 1900) doesn't work (on Windows
anyway), so use an offset:
define('EPOCHINEXCEL', 25568); //01-01-1970 minus 1
function excel2unix($n) {
return mktime(0, 0, 0, 1, $n - EPOCHINEXCEL, 1970);
}
$myexceldate = 38694; //today
echo date('d-m-Y', excel2unix($myexceldate)); //prints 08-12-2005
You may want to extend the function to handle fractions (time of day).
--
E. Dronkert
[Back to original message]
|