Reputation: 183
I am trying to convert an old office excel sheet document data into PHP web based app for searching and other data analysis. Stuck in how to fields called start_date & end_date. This tells me that if project is active or not. Data saved in below format. It compares both dates and return the project status by comparing with current date.
Start_Date End Date Status
1-Jan-16 31-Dec-16 Active or not
I tried with PHP date("Y-m-d") function but month is an issue.
Upvotes: 0
Views: 31
Reputation: 6683
You can use the strtotime()
function on your excel derived dates and then convert it to a usable DateTime value using date()
like so:
$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
Then compare the two dates against each other.
Upvotes: 1