Home  >  Article  >  php教程  >  php计算2个日期的差值函数分享

php计算2个日期的差值函数分享

WBOY
WBOYOriginal
2016-06-06 20:11:391088browse

这篇文章主要介绍了php计算2个日期的差值函数分享,非常实用,推荐给有需要的小伙伴。

非常简单实用的函数分享给大家,,

奉上代码:

复制代码 代码如下:


/**
     *    日期-计算2个日期的差值
     *  @return int
     */
    public function get_difference($date, $new_date) {
        $date = strtotime($date);
        $new_date = strtotime($new_date);
        return abs(ceil(($date - $new_date)/86400));
    }

超级简单,这里就不多废话了,希望小伙伴们能够喜欢。

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