Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jan 2007
    Posts
    217
    Thanks
    9
    Thanked 0 Times in 0 Posts

    timestamp/date help

    Hey,

    I want to display a feature which tells the user when the last time the page was updated in terms of minutes.

    Each time the page is updated, i store the time it was updated in a database table. Then, when i visit the page, the value from the database is taken away from the current time.

    I was wondering how i'd do this? And make it so it only displays minutes, so like, "This page was updated 7 minutes ago."

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    PHP Code:
    // $then = old timestamp
    $mins ceil((time() - $then) / 60);
    echo 
    "This page was updated $mins minute" . ($mins 's' '') . " ago."
    You could use round() or floor() instead of ceil() depending on how you want the result calculated.
    Last edited by Inigoesdr; 08-21-2007 at 11:20 PM.

  • Users who have thanked Inigoesdr for this post:

    ole90 (08-21-2007)

  • #3
    Regular Coder
    Join Date
    Jan 2007
    Posts
    217
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Awesome, thanks, just what i was lookin for :P


  •  

    Posting Permissions

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