Link to home
Start Free TrialLog in
Avatar of saibsk
saibsk

asked on

time difference in minutes using Perl

How do I find the time difference between two times which are in this format using Perl ?

00:05 00:30 ie. 00:30 - 00:005.
ASKER CERTIFIED SOLUTION
Avatar of Adam314
Adam314

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Is your format hour:minutes? Try this

$time1 =  '00:30';
$time2 =  '00:05';

($hour1,$min1) = ($time1 =~ /(\d\d):(\d\d)/);
($hour2,$min2) = ($time2 =~ /(\d\d):(\d\d)/);
$diff_hrs = abs($hour1 - $hour2);
$diff_mins = abs($min1 - $min2);