Results 1 to 3 of 3

Thread: Posted Time ago function

  1. #1
    Join Date
    Jan 2008
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Posted Time ago function

    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

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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)
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jan 2008
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks I have found a readymade function

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •