Home  >  Article  >  Backend Development  >  Find the number of days between two dates using PHP

Find the number of days between two dates using PHP

WBOY
WBOYOriginal
2016-07-25 08:46:05885browse
  1. function maketime($date)
  2. {
  3. list($year,$month,$day) = explode("-",$date);
  4. return mktime(0,0,0, $month,$day,$year);
  5. }
  6. $date1 = "2015-01-01";
  7. $date2 = "2015-01-05";
  8. $d = (maketime($date2) - maketime( $date1)) / (3600*24);
  9. echo "$date1 - $date2
    $d days apart";
  10. ?>
Copy code

PHP


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn