PHP Calculation Date Difference days instance analysis, days instance Analysis _php Tutorial

Source: Internet
Author: User

PHP Calculation Date Difference days instance analysis, days instance analysis


This paper analyzes the method of calculating the date difference between days in PHP. Share to everyone for your reference, as follows:

<? php//today and October 27, 2016 The difference of how many days $date_1=date ("y-m-d"), $Date _2= "2016-10-27"; $d 1=strtotime ($Date _1); $d 2=strtotime ($Date _ 2); $Days =round (($d 1-$d 2)/3600/24); Echo  "Today differs from October 27, 2016". $Days. " Day "; echo"
$date_1=date ("y-m-d"), $Date _2= "2018-09-09", $d 1=strtotime ($Date _1), $d 2=strtotime ($Date _2); $Days =round (($d 2-$d 1)/3600/24); Echo "still has" today to September 9, 2018. $Days. " Days ";? >
---------------------------------------------$arrayStartDate =explode ("/", $myStartDate); $arrayEndDate = Explode ("/", $myEndDate); $jdStartDate = Cal_to_jd (Cal_gregorian, $arrayStartDate [1], $arrayStartDate [ 0], $arrayStartDate [2]); $jdEndDate = Cal_to_jd (Cal_gregorian, $arrayEndDate [1], $arrayEndDate [0], $arrayEndDate [2]); $duration = $jdEndDate-$jdStartDate + 1;

Statistics that expire after a few days

DateDiff (Yxdate_star,now ())

Return days: Yxdate_star-now ()

More readers interested in PHP related content can view the topic: "PHP Primer for Object-oriented programming", "PHP String Usage Summary", "Php+mysql Database Operations Primer" and "PHP common database Operation Skills Summary"

I hope this article is helpful to you in PHP programming.

Articles you may be interested in:

    • Share PHP to calculate the number of days difference between two dates code
    • PHP uses Strtotime to calculate the number of days between a given date two
    • PHP calculates the two-day difference between days
    • PHP code that calculates the number of weekends in a certain date (Saturday, Sunday total)
    • How PHP gets yesterday, today, and tomorrow's date
    • Very comprehensive PHP date-time Operations summary
    • PHP gets constellation information and zodiac information based on date or time stamp
    • How PHP displays your constellation based on date
    • Php method to determine how many months are different between two dates
    • PHP implements a method to compare two string date sizes

http://www.bkjia.com/PHPjc/1102461.html www.bkjia.com true http://www.bkjia.com/PHPjc/1102461.html techarticle PHP Calculation Date Difference Days instance analysis, the number of days instance analysis This article analyzes the PHP calculation date difference of days method. Share to everyone for your reference, as follows: php//today with ...

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