Convert Excel time to Unix time
Filed Under (php) by admin on 02-12-2009
Tagged Under : excel date, excel time, php, unix date, unix time
When dealing in PHP with imported data from excel spreadsheets , you might encounter that excel dates looks very different.
Excel time looks like this 40179
You cannot compare or compute dates in PHP if it looks like that, it should be on unixtime
which looks like this 1104537600
Here is a quick function to convert excel date to unixtime date
<? $DayDifference = 25569; //Day difference between 1 January 1900 to 1 January 1970 $Day2Seconds = 86400;// no. of seconds in a day $ExcelTime = 30128;//integer value stored in the Excel column $ExcelTime = substr($ExcelTime,0,5);//trim excel time get only whole 5 digit $UnixTime = ($ExcelTime - $DayDifference)*$Day2Seconds; echo $UnixTime; ?>


