PHP教程

PHP日期想减 计算两个日期之间相隔多少天

位置:首页 > PHP教程 > PHP技巧,2018-08-15 01:05
PHP日期想减 计算两个日期之间相隔多少天

面向对象风格:

<?php $january = new DateTime('2010-01-01');
$february = new DateTime('2010-02-01');
$interval = $february->diff($january); 
// %a will output the total number of days. 
echo $interval->format('%a total days')."\n";

过程式风格:

<?php $january = date_create('2010-01-01');
$february = date_create('2010-02-01');
$interval = date_diff($january, $february);
 // %a will output the total number of days.
 echo $interval->format('%a total days')."\n";

TAGS:PHP日期想减

上编:PHP将一个数组转换成Xml格式

下编:没有了

猜你喜欢

NewHot