Discussion:
How to convert and calculate date differences?
(too old to reply)
Brian Mantler
2006-08-25 19:48:54 UTC
Permalink
Hi,

I am trying to calculate how long ago a file was archived and take action
if it is too old. I can get the last archived date of a file in a format
such as:

mm/dd/yyyy hh:mm:ss

However when I check the current time I get a big long number of seconds.
I don't know how to convert between the two. Does anyone out there know
how?

Thanks.
Guenter
2006-08-26 01:18:43 UTC
Permalink
Hi Brian,
Post by Brian Mantler
Hi,
I am trying to calculate how long ago a file was archived and take action
if it is too old. I can get the last archived date of a file in a format
mm/dd/yyyy hh:mm:ss
However when I check the current time I get a big long number of seconds.
I don't know how to convert between the two. Does anyone out there know
how?
see my old samples:
http://www.gknw.net/nwperl/perlscripts/abendchk.txt
and probably:
http://www.gknw.net/nwperl/perlscripts/cleanup.txt

Guenter.
Brian Mantler
2006-08-28 16:49:43 UTC
Permalink
Hi,

I have installed the Date:Parse.pm, Date:Format.pm and Time:zone.pm
modules.

When I try to run the following code:

($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)=stat($fullpath);

$Entry = $FileMgr->FindEntry($fullpath) ; # fullpath is the name of a
file
$EntryArc = $Entry->{'ArchiveDate'};
$temp = $EntryArc;
$temp =~ s/\./\:/g; # replace . with : for str2time()
$stamp = Date::Parse::str2time($temp);

I get 'Undefined subroutine &Datte::Parse::str2time'

Ay ideas?

Thanks.
Post by Guenter
Hi Brian,
Post by Brian Mantler
Hi,
I am trying to calculate how long ago a file was archived and take
action if it is too old. I can get the last archived date of a file
mm/dd/yyyy hh:mm:ss
However when I check the current time I get a big long number of
seconds. I don't know how to convert between the two. Does anyone
out there know how?
http://www.gknw.net/nwperl/perlscripts/abendchk.txt
http://www.gknw.net/nwperl/perlscripts/cleanup.txt
Guenter.
Brian Mantler
2006-08-28 19:06:02 UTC
Permalink
Please disregard that last message. I mistyped the use section.

All seems to be working OK.

Thanks.
Post by Brian Mantler
Hi,
I have installed the Date:Parse.pm, Date:Format.pm and Time:zone.pm
modules.
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)=stat($fullpath);
$Entry = $FileMgr->FindEntry($fullpath) ; # fullpath is the name of a
file
$EntryArc = $Entry->{'ArchiveDate'};
$temp = $EntryArc;
$temp =~ s/\./\:/g; # replace . with : for str2time()
$stamp = Date::Parse::str2time($temp);
I get 'Undefined subroutine &Datte::Parse::str2time'
Ay ideas?
Thanks.
Post by Guenter
Hi Brian,
Post by Brian Mantler
Hi,
I am trying to calculate how long ago a file was archived and take
action if it is too old. I can get the last archived date of a file
mm/dd/yyyy hh:mm:ss
However when I check the current time I get a big long number of
seconds. I don't know how to convert between the two. Does anyone
out there know how?
http://www.gknw.net/nwperl/perlscripts/abendchk.txt
http://www.gknw.net/nwperl/perlscripts/cleanup.txt
Guenter.
Loading...