php - Difference in UK Dates -
this question has answer here:
i trying show difference in days , months between 2 dates
$date1 = $start; $date2 = $end; $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)); printf("%d years, %d months, %d days\n", $years, $months, $days);
however shows 0 years, 0 months, 0 days
the dates in $start
, $end
in format dd/mm/yyyy
as have stated within comment the dates in $start
, $end
in format dd/mm/yyyy
. need first replace d-m-y
using str_replace
or datetime::createfromformat
try using as
$date1 = str_replace('/','-',$start); $date2 = str_replace('/','-',$end);
Comments
Post a Comment