Home  >  Article  >  Backend Development  >  php计算2个日期的差值函数分享_PHP

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

WBOY
WBOYOriginal
2016-05-31 13:17:34905browse

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

奉上代码:

代码如下:


/**
     *    日期-计算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