date differnce php
# Current date
$date1 = new DateTime("2018-04-26");
# My born date, lol
$date2 = new DateTime("1997-02-25");
# The DateTime class has a diff() method that is used to compare elements.
# http://php.net/manual/es/function.date-diff.php
$diff = $date2->diff($date1);
# The function can show the years, months, days and other data.
echo $diff->y. ' Years. '
.$diff->m. ' Months. '
.$diff->d. ' Days. ';
?>
No comments:
Post a Comment