0
나는 $ timenow와 $ time의 차이를 계산하려고합니다.2 타임 스탬프 사이의 차이 - PHP
$time = 2016-09-15 20:10:35
$timenow = 2016-09-15 20:40:42
나는 dateTime으로 변환했다.
$interval = $timenow->diff($time);
echo $interval;
오류 : 잡아낼 치명적인 오류 :
$time = new DateTime($time);
$timenow = new DateTime($timenow);
그리고는 계산을 한 클래스 DateInterval의 개체 나는이 difference between 2 timestamps in php 및 Wrong hour difference between 2 timestamps (hh:mm:ss) 보았다 문자열
로 변환 할 수 없습니다
그건 도움이되지 못했습니다.
'$의 interval' 개체입니다, 당신은 그것을 포맷해야합니다. http://php.net/manual/en/datetime.format.php - 예를 들어,'$ interval-> format ('Ymd H : i : s'); ' – Qirel
아마도'format'을 on으로 사용하고 싶을 것입니다 객체 http://php.net/manual/en/dateinterval.format.php –
[DateInterval 클래스의 [php Object] 복제본을 문자열로 변환 할 수 없습니다 (http://stackoverflow.com/questions/28621270/php -object-of-class-dateinterval-could-be-converted-to-string) – HPierce