Calcualte Day difference


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function daysDifference($endDate, $beginDate)
  2. {
  3. //explode the date by "-" and storing to array
  4. $date_parts1=explode("-", $beginDate);
  5. $date_parts2=explode("-", $endDate);
  6. //gregoriantojd() Converts a Gregorian date to Julian Day Count
  7. $start_date=gregoriantojd($date_parts1[1], $date_parts1[2], $date_parts1[0]);
  8. $end_date=gregoriantojd($date_parts2[1], $date_parts2[2], $date_parts2[0]);
  9. return $end_date - $start_date;
  10. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.