Time Function Question
Posted 14 September 2006 - 08:54 PM
I want to show this kinda message "You last logged in '3 days 2 hours and 5 seconds ago".
I have a date and time saved in database, is there a function to calculate the difference between the times?The field in the db is "datetime" but does it have to be "timestamp"?
Posted 14 September 2006 - 09:29 PM
Posted 14 September 2006 - 09:49 PM
Take date 1 and use the date fucntion to return you seconds.
$loggedIn = date("U", mktime(h,m,s,m,d,y));
and right now is
$now = date("U");
take $now - $loggedIn and you now have the SECONDS that have passed between the two dates.
I day is 86400 seconds, 1 hour is 3600 seconds, one minute 60 seconds.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users