How to calulate the difference between a MySQL timestamp and the current time in PHP
Translations
Englishالعربية
български
català
中文
čeština
dansk
Nederlands
eesti
suomi
français
Deutsch
Ελληνικά
עברית
हिंदी
magyar
Bahasa Indonesia
italiano
日本語
한국어
latviešu
lietuvių
norsk
polski
Português
română
русский
slovenčina
slovenski
español
svenska
ไทย
Türkçe
українська
Tiếng Việt
I'm trying to calculate the difference between a timestamp retrieved from a MySQL database and the current time.
Appreciate the help.
This question and answers originated from www.stackoverflow.com
Question by Sid (4/15/2011 11:53:15 AM)
Answer |
As mentioned by @RemoteSojourner, I got the current time in a UNIX timestamp format (which returns time in seconds), I got the timestamp from the DB (using an ORM) and converted that to a UNIX timstamp too and then subtracted the two timestamps.
$current_time = strtotime("now");
$last_access_time = strtotime($this->last_access);
$inactivity_duration = $current_time - $last_access_time;
Answer by Sid
Find More Answers
Related Topics php mysql zend-framework datetime timestamp