http://qs321.pair.com?node_id=270150

ibanix has asked for the wisdom of the Perl Monks concerning the following question:

Hello fellow Monks,

I've been absent from the monstary a long time, with work and such claiming hold of my life. It's appropriate then that I have a fairly simple question to ask on my return.

I have a date field in a file of type 'MM/DD/YYYY' where MM, DD, and YYYY are month, day and year respectively. I need to convert this to 'YYYY-MM-DD'.

I think my obvious approach would be to split the field and rewrite it like so:

$datefield = 'MM/DD/YYYY'; ($mon, $day, $year) = split(/\//,$datefield,3); $finaldate = $year."-".$mon."-".$day;
However, I'd really like to not reinvent well-working wheels -- is there a good date formatting function that will do this? I attempted to make localtime() do what I needed, without immediate success.

Thank you all!
ibanix

$ echo '$0 & $0 &' > foo; chmod a+x foo; foo;