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

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

WBOY
Release: 2016-06-06 20:11:39
Original
1121 people have browsed it

这篇文章主要介绍了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));
    }

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

Related labels:
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template