How to compare two dates in php. I got an array of dates from the database and I want it to compare with todays date.
I have something like this.
$d['dd'] = 10;
$d['mm'] = 12;
$d['yy'] = 13;
Now I have done Something like this:
$date = $d['yy'].'-'.$d['mm'].'-'.$d['dd'];
$date_diff=strtotime(date("y-m-d"))-strtotime($date);
if($date_diff>0){
//this date is gone.
}
// I want to show this day will go in 5 days. To do this I have following.
if((strtotime(date("y-m-d", strtotime(date("y-m-d", strtotime(date('y-m-d'))) . "+ 5 days")))-$date_diff)>0){
// This day will go in 5 days time.
}
Now my question is what is the best way to do this or how can I do it in a better(more reliable) way. Any suggestions will be helpful.
Thanks in advance.