I have a time string, the first user's last login : '2014.12.01, 12:25' And how to calculate the time different from now? For e.g. another user see the first user's last login
At 12:30 and it says 5 minute ago.
Or at 13:23 says 48 minute ago.
Or at 14:24 says 1 hour ago.
Or one day later, it says 1 day ago.
You can try the following:
$to_time = strtotime("2014-12-01 12:25:00");
$from_time = strtotime("2014-12-01 12:25:00");
$minutes = round(abs($to_time - $from_time) / 60,2);
$seconds = abs($to_time - $from_time) % 60;
echo "$minutes minute, $seconds seconds";
It had already been answered at the following link:
Hope this helps
$first_user_time = '2014-12-01 12:30:00';
$curnt_user_time = '2014-12-01 12:40:00';
$diff = date('h:i:s', strtotime($first_user_time)-strtotime($curnt_user_time))
echo $diff;
//it will give diff in hour : min : seconds