在php中查找2个日期之间的天数 [英] Find amount of days between 2 dates in php

查看:89
本文介绍了在php中查找2个日期之间的天数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个日期,想知道他们之间有多少天。

I have 2 dates and want to know how many the amount of days that come between them.

让我们说这两个是日期


2015-11-16 10:01:13

2015-05-06 09:47:16

2015-11-16 10:01:13
2015-05-06 09:47:16

第一个是现在,我如何计算两个给定日期之间的天数?

The first one being right now, how can I calculate how many days are in between the two given dates?

推荐答案

尝试这个。这很简单。

    <?php

     $date1 = strtotime("2015-11-16 10:01:13");
     $date2 = strtotime("2015-05-06 09:47:16");
     $datediff = $date1 - $date2;
     echo floor($datediff/(60*60*24))." days"; //output 194 days

    ?>

这篇关于在php中查找2个日期之间的天数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆