EXCEL的儲存格要套用EXCEL的日期格式的話,必須把日期轉成EXCEL專用的日期格式。
其公式為:
EXCEL_DATE = 25569 + (UNIX_DATE / 86400)
會得出一個浮點數,其中整數部分為日期,小數點部分為時間。
--
反過來要把EXCEL日期轉成timestamp
其公式為:
$UNIX_DATE = ($EXCEL_DATE - 25569) * 86400;
--
參考自 https://www.codegrepper.com/code-examples/php/excel+date+format+in+php
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 putting 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);
留言列表