How To Calculate Dates In Perl Using Date::Manip

Author: , September 18th, 2017

1 2 3 4 my $created_at  = ’2017-09-18T13:43:40Z’; my $marker      = DateCalc(’today’,’30 days ago’); my $cmp = Date_Cmp($created_at,$marker); if ($cmp < 0) { print "Older than marker!\n"; } else { print "Same date or later than marker\n"; } my $created_at = ’2017-09-18T13:43:40Z’; my $marker = DateCalc(‘today’,’30 days ago’); my $cmp = Date_Cmp($created_at,$marker); if […]

How To Get Last Day Of Current Month With Suffix Using PERL

Author: , May 28th, 2011

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 use Date::Manip; my @months = qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/; my $month = $months[ (localtime)[4] ]; my $last = &UnixDate("last saturday in $month", "%B %e"); $last .= &gensuffix($last);   sub gensuffix {   […]

How To Calculate Time In Perl Using Date::Manip OO Mode

Author: , March 22nd, 2011

my $now = new Date::Manip::Date; $now->parse(‘now’); # in GMT $now->convert(‘EST5EDT’); # in Eastern time my $then = new Date::Manip::Date; $then->parse(’200503131131′); # in GMT $then->convert(‘EST5EDT’); # in Eastern time my $delta = $now->calc($then); my @delta = $delta->value(); # get delta values as an array foreach (@delta) { $_ = abs($_); } # remove negative signs my […]