Bladephp: Now with 7+ codeigniter, php, and laravel project 7+ php project From $18/Year From Rs. 1000/Year

How to get year month day difference between two dates using php

by
Category:php
php
How to get year month day difference between two dates using php

There are a simple way to get the number of year month and day between two dates in PHP. Using the formula, you can easily count year month and day between two dates in PHP. You may also like Two date get hour and minute using php and Get total minute and second difference between two dates using php.

Code

$StartDate='2010-02-20';
$EndDate='2011-12-01';
$diff   = abs(strtotime($StartDate) - strtotime($EndDate));
echo 'years = '.$years  = floor($diff / (365*60*60*24));
echo "<br>";
echo 'months = '.$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
echo "<br>";
echo  'days = '.$days   = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));

0 Comments


Html code work in comment box


Related Post