使用PHP Excel Reader读取XLS日期值 [英] Reading xls Date Values with php excel reader

查看:93
本文介绍了使用PHP Excel Reader读取XLS日期值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PHPExcel读取excel文件中的日期单元格,这些单元格的值类似于"Mar-13",但它返回的整数值如"41791".拜托,我该怎么做才能确保正确输入日期?

I am using PHPExcel to read date cells in excel file that have values like 'Mar-13' but it is returning integer values like '41791'. Please, what do I need to do make sure that the date reads in correctly?

推荐答案

Excel将日期存储为序列化时间戳(自1900年1月1日以来的天数),您可以将其转换为Unix时间戳并使用标准php日期函数对其进行格式化

Excel stores dates as serialized timestamps (number of days since 1/1/1900), which you can convert to Unix timestamp and format it with standard php date functions

$unix_timestamp = ($cell_value - 25569) * 86400;
$phpdate = date("m-d-Y", $unix_timestamp);

这篇关于使用PHP Excel Reader读取XLS日期值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆