Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^4: AM/PM to 24 hours

by 0day (Sexton)
on Aug 05, 2013 at 20:29 UTC ( #1047981=note: print w/ replies, xml ) Need Help??


in reply to Re^3: AM/PM to 24 hours
in thread AM to 24 hours

Here is a simple regular expression to convert a string

while (<DATA>) { s/(\d+)\/(\d+)\/(\d+)\s+(\d+):(\d+):(\d+)\s+(PM|AM)/$3.'-'.$1.'-'. +$2.'-'.($7 eq 'PM'?($4+12):$4).'.'.$5.'.'.$6.'.0000'/ge; print $_; } __DATA__ ID,21,11814,1,11989,150,Y,10/25/2012 11:36:25 AM,TEST ID,22,11814,1,11989,150,Y,10/25/2012 11:36:25 PM,TEST
Output:
ID,21,11814,1,11989,150,Y,2012-10-25-11.36.25.0000,TEST
ID,22,11814,1,11989,150,Y,2012-10-25-23.36.25.0000,TEST


Comment on Re^4: AM/PM to 24 hours
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1047981]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2014-08-31 05:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (294 votes), past polls