且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用PHP Excel进行Excel日期转换

更新时间:2023-11-29 12:45:40

请使用此公式将Excel日期更改为Unix日期,然后可以使用"gmdate"在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

并从Unix日期转换为Excel日期,请使用以下公式:

and to convert from Unix date to Excel date, use this formula:

EXCEL_DATE = 25569 + (UNIX_DATE / 86400)

将此公式放入变量后,您可以使用以下示例获取PHP中的实际日期:

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);