in reply to Re^3: Simple (I thought) time comparison?
in thread Simple (I thought) time comparison?
And further illustrating my noob-ness, I didn't include the entire updated script so it actually made sense. Sorry. Here it is:
use strict; use warnings; use Time::Piece; my $ctime = Time::Piece->new; my $oldtime = Time::Piece->strptime('Dec 19 17:44:00 2016', '%b %d %T +%Y'); $oldtime = $oldtime - $ctime->tzoffset; print "The current time is $ctime\n"; print "The old time is ", $oldtime + $ctime->tzoffset, "\n"; my $halfago = $ctime - 1800; print "Half an hour ago is $halfago\n"; if ($oldtime > $halfago) { print "Old time is within a half hour\n"; } else { print "Old time is outside a half hour\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Simple (I thought) time comparison?
by soonix (Chancellor) on Dec 20, 2016 at 09:16 UTC |