I've seen lots of references to converting the "date" portion of the Excel serial date format, but everyone seems to skip the "time" portion of it.
Here is what I need to do:
I have an Excel file I'm importing. PHP in use.
I am encountering the Excel Date Serial format (dddddd.tttttt) and need to convert this to an entire Unix timestamp.
I've tried a few different things, but am getting hung up on how to do this in a fluid motion.
Use this shortcut – Ctrl + ; (Control + semicolon) to insert the current date. Use this shortcut – Ctrl + Shift + ; (Control + Shift + semicolon) to insert the current time. Use this shortcut – Press the combination (Ctrl + ;) and (Ctrl + Shift + ;) to insert the current time and time.
Please use this formula to change from Excel date to Unix date, then you can use "gmdate" to get the real date in PHP:
UNIX_DATE = (EXCEL_DATE - 25569) * 86400
and to convert from Unix date to Excel date, use this formula:
EXCEL_DATE = 25569 + (UNIX_DATE / 86400)
After doing this formula into a variable, you can get the real date in PHP using this example:
$UNIX_DATE = ($EXCEL_DATE - 25569) * 86400;
echo gmdate("d-m-Y H:i:s", $UNIX_DATE);
Thanks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With