Log in

View Full Version : Setting A Future Date



Titan85
07-16-2007, 03:46 PM
Hello, I am trying to make a script that will show "NEW" next to a file that was uploaded within a week of the current date. I am thinking that if I store the date it is uploaded and then create a date a week in the future, I can use the future date as a time to stop showing "NEW". I just do not have an idea on how to detect if it is over a week since the file was uploaded. I am guessing that it will just be a simple if statement like:
if (date() < $stored['date']) { echo('<b>NEW</b>'); } Anyone have an idea? Thanks.

djr33
07-16-2007, 03:53 PM
filemtime() (http://www.php.net/manual/en/function.filemtime.php) is last modifcation time; fileatime() (http://www.php.net/manual/en/function.fileatime.php) is last access time; filectime() (http://www.php.net/manual/en/function.filectime.php) is the last changed time.

I'll use mofication for this example. Play with them to figure out what you want.


$file = //do stuff here;

if (filemtime($file)>=(time()-60*60*24*7)) {
//do stuff here;
}
else { /**/ }

Titan85
07-17-2007, 02:16 PM
Thanks, thats what I am looking for. I'll let you know how it woks out :)