Reputation: 23
For Example:
echo $interval->format('%h.%i Hours');
I want to store it in integer. How do i do it ?
Thanks.
Upvotes: 0
Views: 766
Reputation: 16526
You could do this
$interval = new DateInterval('P2Y4DT6H8M');
$str = $interval->format('%d:%h:%i:%s');
list($days, $hours, $minutes, $seconds) = explode(':', $str);
$elapsedSeconds = ($days*86400) + ($hours*3600) + ($minutes*60) + $seconds;
echo $elapsedSeconds;
Upvotes: 2
Reputation: 1667
Use strtotime :
echo strtotime('2012-03-27 18:47:00');
//--> which results to 1332866820
Upvotes: 0