I read an article about time difference in stackoverflow URL
$datetime1 = new DateTime("2010-06-20");
$datetime2 = new DateTime("2011-06-22");
$difference = $datetime1->diff($datetime2);
echo 'Difference: '.$difference->y.' years, '
.$difference->m.' months, '
.$difference->d.' days';
print_r($difference);
This is a code to calculate time difference as you know , and i need a time diff to insert into db , but if the time diff is less than 0 years it inserts the 0 year too , how can i prevent this?
Aucun commentaire:
Enregistrer un commentaire