Hello All,
I have a requirement to convert a 12 hour format to 24 hour time format and the sample input /out put is below
Input Time format : Nov 2 2011 12:16AM
Out Put Format : Nov 2 2011 0:16
Input : Nov 2 2011 4:16PM
Out Put: Nov 2 2011 16:16
I have done this using a perl script and working absolutely fine -
###############
use strict;
while( my $line = <DATA> ){
$line =~ s/(\d+)(:\d+)(A|P)\.M\,/($3 eq 'a')?($1%12).$2:($1%12+12).$2/e;
print $line;
}
__DATA__
Nov 2 2011 12:41A.M,
Nov 2 2011 12:41A.M,
Nov 2 2011 3:41P.M,
Nov 2 2011 5:41P.M,
###################OUT PUT#############
Nov 2 2011 12:41
Nov 2 2011 12:41
Nov 2 2011 15:41
Nov 2 2011 17:41
My requirement is now :
1) I have file with thousands of records like below and i want to convert each of the records with right time format as i mentioned above.
Nov 2 2011 12:01AM,52893,420,1,4,0,52834,4,1208,67664942,603459924403.0,1,150054,1208,3
Nov 2 2011 5:16PM,52127,420,1,4,0,52122,4,1429,55943831,603459924406.0,1,150054,1429,3
I need to convert the first column match (12:01AM/5:16PM) and convert this to right format
Expected output is :
Nov 2 2011 0:01,52893,420,1,4,0,52834,4,1208,67664942,603459924403.0,1,150054,1208,3
Nov 2 2011 17:16,52127,420,1,4,0,52122,4,1429,55943831,603459924406.0,1,150054,1429,3
I know with little modification to my script this can be acheived but i am not able to match the entire record with regx.
ANY HELP IS MUCH APPRICIATED.