How to Get Difference Between Two Dates in PHP?

How to Get Difference Between Two Dates in PHP?

Rathorji

3 года назад

3,894 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

anuraj ms
anuraj ms - 05.12.2021 02:56

another easy way
$start = date_create('1987-06-03');
$end = date_create(); // Current time and date
$diff = date_diff($start, $end);
echo "<br>";

echo 'The difference is ';
echo $diff->y . ' years, ';
echo $diff->m . ' months, ';
echo $diff->d . ' days, ';
echo $diff->h . ' hours, ';
echo $diff->i . ' minutes, ';
echo $diff->s . ' seconds';
// Output changes based on the current time: The difference is 28 years, 5 months, 19 days, 20 hours, 34 minutes, 36 seconds

echo 'The difference in days : ' . $diff->days;
// Output: The difference in days : changes based on parameters

Ответить
Bikram Acharjee
Bikram Acharjee - 20.10.2021 17:39

Exact ans is 1 year 10 month 27 days

Ответить
Bikram Acharjee
Bikram Acharjee - 20.10.2021 17:34

Result is wrong bro. Check it

Ответить