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?
Re: Is this possible? Displaying 'New' based on folder dates
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.
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.
Re: Is this possible? Displaying 'New' based on folder dates
This is the code I am using
VB Code:
$folderInfo = stat($filename);
$tempinfo = $folderInfo[9];
$tempinfo = $tempinfo+(7*24*60*60);
$nowtime = time();
if ($tempinfo >= $nowtime) {
echo "<br><font class=swap><strong>New Photos</strong></font>";
}
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.