Home > Backend Development > PHP Tutorial > PHP uses strtotime to calculate the number of days between two given dates, strtotime days_PHP tutorial

PHP uses strtotime to calculate the number of days between two given dates, strtotime days_PHP tutorial

WBOY
Release: 2016-07-13 10:03:01
Original
1115 people have browsed it

PHP uses strtotime to calculate the number of days between two given dates, strtotime days

This article describes the example of PHP using strtotime to calculate the number of days between two given dates. . Share it with everyone for your reference. The specific analysis is as follows:

PHP’s strtotime function is used to parse the date-time description of any English text into a Unix timestamp. This function will use the TZ environment variable (if available) to calculate the timestamp. It returns a timestamp if the execution is successful, otherwise it returns FALSE. Prior to PHP 5.1.0, this function would return -1.

$date1 = date('Y-m-d');
$date2 = '2005-03-01′;
$days = (strtotime() – strtotime()) / (60 * 60 * 24);
echo "Number of days since '2005-03-01′: $days";
Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/969480.htmlTechArticlePHP uses strtotime to calculate the number of days between two given dates. The number of days in strtotime is an example of how PHP uses strtotime. A method for calculating the number of days between two given dates. Share with everyone...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template