PHP calculate the number of days for date difference instance analysis, number of days for instance Analysis _ PHP Tutorial

Source: Internet
Author: User
PHP calculates the number of days for date difference instance analysis and number of days for instance analysis. Example of calculating the number of days of a date difference in PHP. This article is for your reference. The details are as follows: analysis of the number of days of calculation difference between PHP and PHP today, and analysis of the number of days of calculation.

This article describes how to calculate the number of days for date difference in PHP. We will share this with you for your reference. The details are as follows:

<? PHP // how many days are there today different from January 1, October 27, 2016 $ Date_1 = date ("Y-m-d"); $ Date_2 = "2016-10-27"; $ d1 = strtotime ($ Date_1 ); $ d2 = strtotime ($ Date_2); $ Days = round ($ d1-$ d2)/3600/24); echo "today is different from October 27, 2016 ". $ Days. "Day"; echo"
"; // How many days are there between today and January 1, September 9, 2018 $ Date_1 = date (" Y-m-d "); $ Date_2 =" 2018-09-09 "; $ d1 = strtotime ($ Date_1 ); $ d2 = strtotime ($ Date_2); $ Days = round ($ d2-$ d1)/3600/24); echo "today to September 9, 2018 ". $ Days. "Day";?>
//---------------------------------------------$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;

Count the expired data in a few days

datediff(yxdate_star,now())

Returned days: yxdate_star-now ()

Related Article

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.