当前位置:Gxlcms > PHP教程 > PHP求两个日期相差的天数

PHP求两个日期相差的天数

时间:2021-07-01 10:21:17 帮助过:13人阅读

  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 天";
  10. ?>

PHP

人气教程排行