Home  >  Article  >  Backend Development  >  P使用strtotime计算两个给定日期之间天数的方法_PHP教程

P使用strtotime计算两个给定日期之间天数的方法_PHP教程

WBOY
WBOYOriginal
2016-07-13 10:02:38945browse

P使用strtotime计算两个给定日期之间天数的方法

 这篇文章主要介绍了PHP使用strtotime计算两个给定日期之间天数的方法,实例分析了php操作时间的技巧,非常具有实用价值,需要的朋友可以参考下

 

 

本文实例讲述了PHP使用strtotime计算两个给定日期之间天数的方法。分享给大家供大家参考。具体分析如下:

PHP的strtotime函数用于将任何英文文本的日期时间描述解析为Unix时间戳。这个函数将使用TZ环境变量(如果有的话)来计算时间戳。如果执行成功它返回一个时间戳,否则返回FALSE。在PHP 5.1.0之前,这个函数将返回-1。

?

1

2

3

4

$date1 = date('Y-m-d');

$date2 = '2005-03-01′;

$days = (strtotime() – strtotime()) / (60 * 60 * 24);

echo "Number of days since '2005-03-01′: $days";

希望本文所述对大家的php程序设计有所帮助。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/969966.htmlTechArticleP使用strtotime计算两个给定日期之间天数的方法 这篇文章主要介绍了PHP使用strtotime计算两个给定日期之间天数的方法,实例分析了php操作时间...
Statement:
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