Php calculates the number of days to the specified date. php date _ PHP Tutorial

Source: Internet
Author: User
Php calculates the number of days to the specified date, which is the php date. Php calculates the number of days to the specified date. The php date example in this article describes how many days php calculates the number of days to the specified date. Share it with you for your reference. The details are as follows: php calculates the number of days to the specified date.

This example describes how many days php calculates to the specified date. Share it with you for your reference. The details are as follows:

function countdays($d){ $olddate = substr($d, 4); $newdate = date(Y) ."".$olddate; $nextyear = date(Y)+1 ."".$olddate;  if($newdate > date("Y-m-d"))  {  $start_ts = strtotime($newdate);  $end_ts = strtotime(date("Y-m-d"));  $diff = $end_ts - $start_ts;  $n = round($diff / 86400);  $return = substr($n, 1);  return $return;  }  else  {  $start_ts = strtotime($nextyear);  $end_ts = strtotime(date("Y-m-d"));  $diff = $end_ts - $start_ts;  $n = round($diff / 86400);  $return = substr($n, 1);  return $return;  }}

I hope this article will help you with php programming.

The example in this article describes how many days php calculates to the specified date. Share it with you for your reference. Details :...

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.