Excel工作表的PHP日期问题

时间:2017-01-24 06:12:55

标签: php

我正在尝试将旧的办公室Excel Excel文档数据转换为基于PHP web的应用程序,以进行搜索和其他数据分析。困在如何调用start_date&的字段中结束日期。这告诉我,如果项目是活跃的。数据以下列格式保存。它比较两个日期并通过与当前日期进行比较来返回项目状态。

Start_Date  End Date  Status
1-Jan-16    31-Dec-16  Active or not

我尝试使用PHP日期(" Y-m-d")功能,但月份是一个问题。

1 个答案:

答案 0 :(得分:1)

您可以在excel派生日期使用strtotime()函数,然后使用date()将其转换为可用的DateTime值,如下所示:

$time_before = strtotime('1-Jan-16');
$date_before = date('Y-m-d', $time_before); // 2016-01-01

$time_after  = strtotime('31-Dec-16');
$date_after  = date('Y-m-d', $time_after); // 2016-12-31

然后compare the two dates against each other