Results 1 to 5 of 5

Thread: Is this possible? Displaying 'New' based on folder dates

  1. #1

    Thread Starter
    Fanatic Member neicedover1982's Avatar
    Join Date
    Jun 2005
    Posts
    566

    Is this possible? Displaying 'New' based on folder dates

    Please tell me if what I am thinking is even possible. I have these folders in my photo album. What I would like to do is the following.

    Display "New Photos" if the creation date of a folder is within 10 days of the current date.

    This way if the date that a fodler was created was...12/10/05, they under the link the text "New Photos" would be written until the date...12/20/05. Then after that its no longer shown.

    I would like to use either the creation date or the modified date because I plan to add folders and images into them on my webserver and would like visitors to see when things have been modified. Is this possible with PHP. I have looked all over google and such and have not found any way to do this.

    As a side not, does folders on webservers even show things such as modified dates?
    Kevin | New England Iced Over | http://www.kevincawleyjr.com

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Is this possible? Displaying 'New' based on folder dates

    Try the stat() function.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Fanatic Member neicedover1982's Avatar
    Join Date
    Jun 2005
    Posts
    566

    Re: Is this possible? Displaying 'New' based on folder dates

    Ok, that worked, I got the date that the folder was modified. Now I need to get the current date and compare the 2. I have never worked with dates before.

    Since stat() gives the unix date, is there an easy way to add 10 to this date and then compare with the current date. If the current date is less then the unix+10, show NEW, else dont show anything?

    Please help.
    Kevin | New England Iced Over | http://www.kevincawleyjr.com

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Is this possible? Displaying 'New' based on folder dates

    Unix timestamps are just seconds since the unix epoch. To add 10 days, you need to add 10*24 hours, is 10*24*60 minutes, is 10*24*60*60 seconds.

    Then you get the current timestamp using time() and compare.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    Fanatic Member neicedover1982's Avatar
    Join Date
    Jun 2005
    Posts
    566

    Re: Is this possible? Displaying 'New' based on folder dates

    This is the code I am using
    VB Code:
    1. $folderInfo = stat($filename);
    2. $tempinfo = $folderInfo[9];
    3. $tempinfo = $tempinfo+(7*24*60*60);
    4. $nowtime = time();
    5. if ($tempinfo >= $nowtime) {
    6.     echo "<br><font class=swap><strong>New Photos</strong></font>";
    7. }

    Right now they all say New Photos becuase i just edited the folders. If i make the 7 into a 0, so its just comparing the modified date to the current date it doenst display anything, like its ment to be. I will check later to see if it does work with the 7 days or not.
    Kevin | New England Iced Over | http://www.kevincawleyjr.com

Posting Permissions

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



Click Here to Expand Forum to Full Width