Please look at the module DateTime or Date::Calc and replace your code with calls to it.
The following is undebugged and untested, so you're welcome to fix any minor issues that show up. :-)
use strict; use warnings; use DateTime; use DateTime::Duration; use DateTime::Format::Strptime; sub timeDiff { # invoke isn't used, what's it for? my $invoke = shift || ''; my $date1 = shift || ''; my $date2 = shift || ''; my $dParser = DateTime::Format::Strptime->new( pattern => '%F %T', locale => 'en', time_zone => 'CET', on_error => 'croak', ); my $dt1 = $dParser->parse_datetime($date1); my $dt2 = $dParser->parse_datetime($date2); my $dur = $dt2 - $dt1; my ($dd, $hh, $mm, $ss) = $dur->in_units('days', 'hours', 'minutes +', 'seconds'); return "$dd J $hh H $mm M $ss Sec"; }
In reply to Re: DIfference in days hours and second between dates
by space_monk
in thread DIfference in days hours and second between dates
by *alexandre*
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |