카테고리 없음
[PHP] PHP 계산 시간
필살기쓰세요
2021. 1. 18. 20:09
대신 다음과 같은 것을 원할 것입니다.
$hours = date('H:i' , strtotime('03:00 - 02:00'));
또는:
$hours = date('H:i' , strtotime('03:00 - 2 hours'));
이것은 인쇄 01:00
됩니다.
https://3v4l.org/on4JH
-------------------DateTime 개체를 사용하여 수행 할 수 있습니다.
$date1 = new DateTime('03:00');
$date2 = new DateTime('02:00');
$dateInterval = $date1->diff($date2);
echo $dateInterval->format('%H:%S'); // result would be 01:00
출처
https://stackoverflow.com/questions/39916074