hanlonj Posted September 14, 2006 Share Posted September 14, 2006 Hi,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"?John Quote Link to comment Share on other sites More sharing options...
onlyican Posted September 14, 2006 Share Posted September 14, 2006 current time - that time Quote Link to comment Share on other sites More sharing options...
bholbrook Posted September 14, 2006 Share Posted September 14, 2006 PHP does not have a datediff function like ASP, but it is relatively easy.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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.