www.webdeveloper.com
Results 1 to 7 of 7

Thread: Time Function - show time passed

  1. #1
    Join Date
    Aug 2008
    Posts
    42

    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
    Posts
    42

  4. #4
    The one and only.

  5. #5
    Join Date
    Aug 2008
    Posts
    42
    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
    Location
    Ankh-Morpork
    Posts
    19,529
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

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



Recent Articles