内容纲要

[code language=”php”]
$to = \Carbon\Carbon::createFromFormat(‘Y-m-d H:i:s’, ‘2017-5-6 3:30:10’);
$from = \Carbon\Carbon::createFromFormat(‘Y-m-d H:i:s’, ‘2017-5-6 3:35:35’);
$diff_in_seconds = $to->diffInSeconds($from);
print_r($diff_in_seconds); // Output: 325
$diff_in_minutes = $to->diffInMinutes($from);
print_r($diff_in_minutes); // Output: 5
$diff_in_hours = $to->diffInHours($from);
print_r($diff_in_hours); // Output: 0
[/code]

发表评论

电子邮件地址不会被公开。 必填项已用*标注