Avatar of farzanj
farzanj
Flag for Canada asked on

Perl converting time string to date/time

I need to convert dates like Jul 09 2012 05:59:59 to YYYY-MM-DD HH24:MI:SS format.

Constraints:
I prefer if I don't have to write the whole thing myself which I would do as a last resort.
I prefer not to use modules.
If a module is required, it would be better to use a more common module so that the code doesn't break on most machines.
Perl

Avatar of undefined
Last Comment
farzanj

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
FishMonger

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
ozo

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
farzanj

ASKER
Thank you guys.  Great!!

Ozo, please explain what you are doing in the second line?  Making an hash or array?  How?
ozo

@m{qw(Jan Feb Mar ... )} is a shorthand for
($m{Jan},$m{Feb},$m{Mar},...)
('01'..'12') is a shorthand for
('01','02','03',...)
so the entire assignment is a shorthand for
$m{Jan}='01'; $m{Feb}='02'; $m{Mar}='03'; ...

(the first 3 ... above are not the perl ... operator)
farzanj

ASKER
Thanks Ozo :)
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck