So I'm making a script to tell when the person's last action on the game was, and I don't want to just put it as "Last action was at blah blah.", I want to be like "It was 2 hours, 3 minutes ago." or something like.
Basically what will happen is their last action goes into the DB, then I use date(); to "subtract" the other time from now. Unfortunately I have no idea how to go about this, and the date(); talk on PHP website is confusing as usual.
Subtracting time and whatnot.
Moderator: General Moderators
-
Mightywayne
- Forum Contributor
- Posts: 237
- Joined: Sat Dec 09, 2006 6:46 am
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Subtracting time and whatnot.
Use Unix timestamps and subtract the current time from the previous. That will give you the elapsed time in seconds. Then divide by 60*60 for hours and the remainder by 60 for seconds.
(#10850)
-
Mightywayne
- Forum Contributor
- Posts: 237
- Joined: Sat Dec 09, 2006 6:46 am
Re: Subtracting time and whatnot.
Perfection. Thanks.