How to format timestamps M/D/Y h:mm:ss AMPM (e.g., 4/8/2013 6:09:03 PM)?by Jim (Curate)
|on May 13, 2013 at 19:51 UTC||Need Help??|
Jim has asked for the
wisdom of the Perl Monks concerning the following question:
I'm doing this…
…to convert timestamps from this format…
04/08/2013 06:09:03 PM
…into this format…
4/8/2013 6:09:03 PM
…after having already converted them from this format…
…using DateTime::Format::Strptime. I'd obviously prefer to specify a DateTime::Format format that does the whole job in one fell swoop. Is there a DateTime::Format module that accomplishes this directly? Am I making this more difficult than I should be? Am I missing something?
Here's a complete script that demonstrates what I'm currently doing:
UPDATE: I discovered $DateTime::format_cldr() soon after posting this inquiry. It seems to work! I'd appreciate suggestions for improvements in any case.
Here's the revised demonstration script: