How to calculate the difference of datetime field and now in PHP?
datetime, php
Solution
Here is the answer :)
$now = new DateTime();
$date = new DateTime("2012-05-03 17:34:01");
echo $date->diff($now)->format("%d days, %h hours and %i minutes");
Problem
I have a datetime field in my database that contains the following information: ``` 2012-05-03 17:34:01 ``` I want to check the difference between the datetime field and now: ``` $now = date("Y-m-d H:i:s"); ``` I am attempting to work out how many days have passed between now and the time written to the database field. How can I achieve this?