Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-06-13 09:15:50
Original
872 people have browsed it

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

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

奉上代码:

复制代码 代码如下:


/**
     *    日期-计算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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!