PHP calculates the two date difference days method, PHP date difference days _php tutorial

Source: Internet
Author: User
Tags diff

PHP calculates a two-day difference between days, PHP date Difference days


This example describes how PHP calculates the two-day difference between days. Share to everyone for your reference. The implementation method is as follows:

<?php/** * Ask for a difference between two dates * (Taylor formula can be used before January 1, 1970) * @param string $day 1 * @param string $day 2 * @return number */FU Nction Diffbetweentwodays ($day 1, $day 2) {  $second 1 = strtotime ($day 1);  $second 2 = strtotime ($day 2);     if ($second 1 < $second 2) {    $tmp = $second 2;    $second 2 = $second 1;    $second 1 = $tmp;  }  Return ($second 1-$second 2)/86400;} $day 1 = "2013-07-27"; $day 2 = "2013-08-04"; $diff = Diffbetweentwodays ($day 1, $day 2); Echo $diff. " \ n ";

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/967741.html www.bkjia.com true http://www.bkjia.com/PHPjc/967741.html techarticle PHP calculates the two date difference days method, PHP date difference of days This example describes how PHP calculates the two date difference between days. Share to everyone for your reference. Concrete Implementation Method ...

  • 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.