How to calculate the difference function between two dates in php? tutorial on calculating the difference function in php

Source: Internet
Author: User
Use php to calculate the difference function of two dates. use php to calculate the difference function. The difference function of php computing two days is shared. The difference function of php computing is very simple and practical. the code is as follows: * ** date-calculate two dates. php calculates the difference function of two dates. php calculates the difference function.

Very simple and practical functions to share with you,

Code:

The code is as follows:


/**
* Date-calculate the difference between two dates
* @ Return int
*/
Public function get_difference ($ date, $ new_date ){
$ Date = strtotime ($ date );
$ New_date = strtotime ($ new_date );
Return abs (ceil ($ date-$ new_date)/86400 ));
}

It's super simple. I don't need to talk nonsense here. I hope my friends will like it.

The following code is provided to share functions that are very simple and practical. the code is as follows:/*** date-calculate two dates...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.