Date difference using PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
<?php // start date comes here $start_date='2010-11-10'; //end date come here-or you can use today's timestamp $end_date='2014-06-16'; //converting the start and end date to timestamp $start_date_timestamp=strtotime($start_date); $end_date_timestamp=strtotime($end_date); $time_difference=abs($start_date_timestamp - $end_date_timestamp); echo $time_difference; //ouput:113526000 // Converting this difference as in days //difference in days $days = $time_difference/(60*60*24); echo 'Days '.$days; //ouput:1313.9583333333 //difference in months $months = $time_difference/(60*60*24*30); echo 'Months '.$months; //ouput:43.798611111111 //difference in Years $years = $time_difference/(60*60*24*365); echo 'Years '.$years ; //ouput: 3.5998858447489 ?> |