php - Finding the number of days between two dates which is stored in m/d/Y format -
this question has answer here:
- finding number of days between 2 dates 21 answers
i want calculate expiry date
percentage.but starting date
, expirydate
in m/d/y
format.how find number of days between starting date
, ending date
???this code...
foreach ($result['query'] $row) { $validitystart = $row->validitystart; $expirydate = $row->expirydate; $today = date('m/d/y'); $maxdiff = date_diff($expirydate, $validitystart); $diff = date_diff($expirydate, $today); $percentage = ($diff * 100) / $maxdiff; }
among hundreds of duplicates here on stackoverflow, might have found bit of searching
$date1 = datetime::createfromformat('m/d/y', $date1); $date2 = datetime::createfromformat('m/d/y', $date2); $diffdays = $date2->diff($date1)->format("%a");