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 4 of 4
  1. #1
    Regular Coder GSimpson's Avatar
    Join Date
    Aug 2006
    Location
    New Zealand
    Posts
    268
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Time Since Entry

    Heya,

    I was on bebo earlier, and saw the comments say "1 Hour Ago", I was wondering if I had a mysql row that had a timestamp under the name "date", how could I have it so that if timestamp less than thirty days old, it would echo <img src="images/layout/new.gif" alt="New Product!"/> but if it was older than 30 days, it wouldn't echo anything.

    I have thought about it and there must be specific functions, that compare that timestamp to the timestamp of now, it seems like something php wud have.

  • #2
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    An if statement could fix that.

    if comment_date => 30 days { //not sure about the => or <= or ==
    <img src="images/layout/new.gif" alt="New Product!"/>
    }
    else
    {
    echo "Older than 30 days"
    }
    Thanks for you support!

  • #3
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    PHP Code:
    $then time() - (60 60 24 30);
    if(
    $date $then)
    {
        
    // more than 30 days ago
    }
    else
    {
        
    // less than 30 days ago

    There are probably hundreds of ways of doing this.

    Date and Time Functions

  • The Following 2 Users Say Thank You to Inigoesdr For This Useful Post:

    GSimpson (08-25-2007), westmatrix99 (08-21-2007)

  • #4
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    That was quick, and I think that should work.
    Thanks for you support!


  •  

    Posting Permissions

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