Find the number of days between two dates using PHP

WBOY
Release: 2016-07-25 08:46:05
Original
911 people have browsed it
  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


source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!