Hi all, I have a Perl script that uses Date::Calc to calculate difference between two datetime variables using Decode_Month and Delta_YMDHMS.
( $yy, $mm, $dd, $hh, $mi, $ss ) = Delta_YMDHMS( $logical_yy, $logical_mm, $logical_dd, $logical_hh, $logical_mi, $logical_ss, $primary_yy, $primary_mm, $primary_dd, $primary_hh, $primary_mi, $primary_ss ); At the moment, the script works well if the datetime format is 01/Jan/2010 20:01:27, i.e. DD/MON/YYYY HH:MI:SS with the time in a 24-hour format. Unfortunately, I suddenly have to to deal with an input file where the datetime format is 02-Apr-2010 3:41:23 p.m., i.e. DD-MON-YYYY HH:MI:SS a.m./p.m., so now my Delta_YMDHMS does not work as expected. For example, my current script calculate time difference between 02-Apr-2010 3:41:23 p.m. and 02-Apr-2010 12:59:48 p.m. as 9 hours, 18 minutes and 25 seconds instead of 3 hours 18 minutes and 25 seconds. Can anyone from the list advise if there is any way to convert the 12-hour format to 24-hour fomat? At the moment, am looking at having to follow as suggested in http://stackoverflow.com/questions/440061/convert-12-hour-date-time-to-24-hour-date-time. That is a bit complicated so am kinda hoping there is a quicker and easier way. I can't see anything from Date::Calc documentation that mention whether converting between 12-hour to 24-hour format is possible or not. Any quick response will be very much appreciated as I needed to get this done quite urgently. Thanks in advance. Still Googling for the meantime ... :-)