将FULL Excel日期序列格式转换为Unix时间戳 [英] Convert the FULL Excel date serial format to Unix timestamp
问题描述
我已经看到了很多有关转换Excel序列日期格式的日期"部分的参考,但是每个人似乎都跳过了它的时间"部分.
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.
这是我需要做的:
我有一个要导入的Excel文件.使用PHP.
I have an Excel file I'm importing. PHP in use.
我遇到了Excel Date Serial格式(dddddd.tttttt),需要将其转换为整个Unix时间戳.
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.
推荐答案
请使用此公式将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 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);
谢谢.
这篇关于将FULL Excel日期序列格式转换为Unix时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!