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;
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.