Results 1 to 7 of 7

Thread: Time Function - show time passed

  1. #1
    Join Date
    Aug 2008

    Time Function - show time passed

    Anyone know a good function for calculate time passed?

    For instance, you feed it a unix timestamp

    and it returns any other following (depending on date):

    1 minute ago
    10 minutes ago
    1 hour ago
    5 hours ago
    3 days ago
    1 month ago
    6 months ago
    1 year ago

  2. #2

  3. #3
    Join Date
    Aug 2008

  4. #4
    The one and only.

  5. #5
    Join Date
    Aug 2008
    Quote Originally Posted by NXInteractif View Post
    The one and only.
    i was being sarcastic.

    date and mktime are the most general functions out there.

  6. #6
    That's because that's all you need.
    mktime() will return the current timestamp given the current date().
    And then you simply subtract the timestamp tkane from the mktime() of the current date minus the mktime() of the date in the past.
    Then you take that value and convert back from the timestamp into a date string.

    php.net - that's it

  7. #7
    Join Date
    Aug 2004
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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