Page 1 of 1

how to compare date and time

Posted: Sat May 28, 2005 9:09 am
by itsmani1

Code: Select all

$year = "2005"; //Year
$month = "06"; //Month
$day = "29"; //Day
now what i want is just to comapre the above given date with todays date and get the difference in days?
any help plz.

Posted: Sat May 28, 2005 9:22 am
by ropson

Code: Select all

$year = "2005"; //Year
$month = "06"; //Month
$day = "29"; //Day
$yourDate=$year.'-'.$month.'-'.$day;
$today=date('Y-m-d');
$days=(strtotime($yourDate)-strtotime($today))/86400;
echo $days;