Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Unix date/time variance

by pepik_knize (Scribe)
on May 22, 2002 at 05:33 UTC ( #168360=note: print w/replies, xml ) Need Help??


in reply to Unix date/time variance

Hmm, very interesting. Which unix platform is giving you problems? It worked fine on linux and solaris for me. If I had to guess, I'd say that maybe your hardware clock is not in synch with your system time. Another option is to use the  -M file test. It returns the value you're looking for in days. Multiplying that by 24, 60, and then 60 again brings it back to seconds. See below, though, because the two methods don't agree. Well, see if this helps anyway:
#!/usr/bin/perl -w use strict; system ("ls"); print "file? "; chomp (my $file = <>); my $lockfile_epoch = (stat($file))[9]; my $current_epoch = time(); my $sttime = $current_epoch - $lockfile_epoch; # using stat print "$sttime\n"; my $fttime = (-M $file)*24*3600; # using file test print "$fttime\n";

Pepik

Of all the causes that conspire to blind
Man's erring judgment, and misguide the mind,
What the weak head with strongest bias rules,
Is pride, the never-failing vice of fools.
-- Pope.
(Humble to be American.)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://168360]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2022-08-19 18:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?