【发布时间】:2016-04-21 20:00:47
【问题描述】:
我正在尝试比较两个日期 - 以分钟为单位检查它们之间的差异。 我的代码是:
$first_date = new DateTime($token->created_at);
$first_date->format('Y-m-d H:i:s');
$second_date = new DateTime();
$second_date->format('Y-m-d H:i:s');
$difference = $first_date->diff($second_date);
$time_diff = $difference->format("%i");
var_dump($first_date);
//I get this object
object(DateTime)#552 (3) {
["date"]=>
string(26) "2016-04-21 10:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
如何从这个 DateTime 对象中获取日期,所以我应该比较两个日期并检查它们之间的差异。 谢谢。
【问题讨论】: