$startdate = new DateTime("2013-11-15");
$enddate = new DateTime("2013-11-20");
$timestamp_start = strtotime($startdate);
$timestamp_end = strtotime($enddate);
$difference = abs($timestamp_end - $timestamp_start);
$days = floor($difference/(60*60*24));
echo " ";
echo 'Days '.$days;
$months = floor($difference/(60*60*24*30));
echo 'Months '.$months;
$years = floor($difference/(60*60*24*365));
echo 'Years '.$years ;
echo " ";
before you answer, let me clariofy that my hosting provider doesnt support the version of php higher than 5.2, so dont suggest diff and interval functions.
i am getting Warning: strtotime() expects parameter 1 to be string, please help.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…