Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: How do I determine if a file was modified today?

by mpolo (Chaplain)
on Jun 02, 2001 at 10:24 UTC ( #85170=note: print w/replies, xml ) Need Help??

in reply to How do I determine if a file was modified today?

Well, stat() gives you epoch seconds since last modification. Then you'll need to get the epoch seconds for 12:00 am on the present date -- use localtime() to get the day, month, and year, then pass those back to timelocal() with hours, minutes, and seconds set to zero to get the time of midnight. Now any file for which the stat() time is greater than the time of midnight was made today.
use Time::Local; my $mtime=(stat("filename.extension"))[13]; my ($day, $month, $year)=(localtime())[3,4,5]; my $midnight=timelocal(0,0,0,$day,$month,$year); unlink ("filename.extension") if ($mtime>$midnight);

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://85170]
[GotToBTru]: Several Species of Small Furry Animals Gathered Together in a Cave and Grooving with a .. Copt? No, that can't be right

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2017-04-24 21:07 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (447 votes). Check out past polls.