Hello,
Here Example of get difference between two dates in year,month and days.
You can use strtotime() to convert two dates to unix time and then calculate the number of seconds between them. From this it's rather easy to calculate different time periods.
<?php
$date1 = "2014-03-24";
$date2 = "2015-06-26";
$diff = abs(strtotime($date2) - strtotime($date1));
$years = floor($diff / (365*60*60*24));
$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
echo "Get Your Year diffrernce:-".$years."year";
echo "<br/>";
echo "Get Your Year diffrernce:-".$months."months";
echo "<br/>";
echo "Get Your Year diffrernce:-".$days."days";
Here Example of get difference between two dates in year,month and days.
You can use strtotime() to convert two dates to unix time and then calculate the number of seconds between them. From this it's rather easy to calculate different time periods.
<?php
$date1 = "2014-03-24";
$date2 = "2015-06-26";
$diff = abs(strtotime($date2) - strtotime($date1));
$years = floor($diff / (365*60*60*24));
$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
echo "Get Your Year diffrernce:-".$years."year";
echo "<br/>";
echo "Get Your Year diffrernce:-".$months."months";
echo "<br/>";
echo "Get Your Year diffrernce:-".$days."days";
0 komentar:
Post a Comment