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.
任何请帮助我将其转换回原始日期格式,尝试使用strtotime($startDate)并给出非常错误的答案!
strtotime($startDate)
$startDate = '2012-11-21T20:16:14+02:00'; $endDate = '2012-11-27T23:19:14+02:00'; $date = 2012-11-26; $time = 20:16:14; $duration = $endDate - $startDate; // 01:30:00
这应该有效:
$startDate = '2012-11-21T20:16:14+02:00'; $endDate = '2012-11-27T23:19:14+02:00'; $duration = strtotime($endDate) - strtotime($startDate); // 60 seconds * 60 minutes * 24 hours $days = round($duration / (60 * 60 * 24)); echo 'days difference: '.$days;