Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: 如何使用 PHP 计算两个日期之间的差异?
我有两次这种格式的时间:date("Y-m-d H:i:s"). 如何计算这两个时间之间的差异?
date("Y-m-d H:i:s")
使用DateTime类和diff方法。
尝试这个:
<?php $datetime1 = date_create($start); $datetime2 = date_create($end); $interval = date_diff($datetime1, $datetime2); return $interval->format('%a'); //returns the number of days ?>