in reply to execute if date is greater then 2hours
(Edit: As haukex mentions below, DateTime has date/time "mathematics" methods, if you need them. It wasn't clear to me from your question whether you need that or whether you are wanting to know the difference between the hour components of your dates, which is what I show here.)
Try something simpler.
Output:use strict; use warnings; use feature 'say'; use DateTime::Format::Strptime; my $parser = DateTime::Format::Strptime->new( pattern => '%F %T', ); my $now = DateTime->now->hour; my $evt = $parser->parse_datetime('2017-06-15 13:14:31')->hour; my $diff = $now - $evt; say "now: $now"; say "evt: $evt"; say "diff: $diff"; __END__
$ perl 1193762.pl now: 7 evt: 13 diff: -6
Hope this helps!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: execute if date is greater then 2hours
by snehit.ar (Beadle) on Jun 28, 2017 at 10:43 UTC |