Log in

View Full Version : Posted Time ago function



shnawer
01-19-2010, 05:45 PM
Hello everybody!

I have seen on many websites. how i can show on my post etc "Posted 2 min ago" I am using mysql. If someone got the function please post it.

Thanks
Emraan

djr33
01-20-2010, 01:37 AM
You can search google for an existing function.
Basically, this is done using if statements then formatting the time.

Use timecodes (number of seconds)

$timenow - $timethen = $timeago;

Then see how "big" $timeago is.

If it's less than 30*60 (30 minutes), then round to nearest minute and display "X minutes ago"
If it's less than (24*60*60)-30 ) (23h30m) then round and display "X hours ago"
Then if not display days (or you can include weeks, months, years, whatever)

shnawer
01-21-2010, 07:37 PM
Thanks I have found a readymade function