Date formatting



I am a Perl newbie and I would like to ask for some advice.

I need to manipulate the date format.
I receive $date in this format: yyyymmdd (For example: 20051230)
I need to display it as "December 30, 2005"

This is what I came up with to accomplish this task:

-----------------------------------------------------------------------------------------------
my @items = $date =~ m/(\d{4})(\d{2})(\d{2})/;
my $formatted_date = POSIX::strftime("%B %e, %Y",
localtime(timelocal(0,0,0,$items[2],$items[1]-1,$items[0])));
-----------------------------------------------------------------------------------------------

The above code is working just fine, but I am wondering if this is
actually a good way of doing this? Is there a more elegant way?

Any advice or comments would be appreciated!

Thank you
stagepin

.



Relevant Pages

  • Re: Standardizing Date Fields
    ... Allan's advice is sound, but I guess it depends on exactly how you plan to ... If you're never going to manipulate the date in any way, ...
    (microsoft.public.access.forms)
  • Re: Aargh!
    ... Wild Monkshood wrote: ... the party that you are trying to manipulate, in a good way, is not in the wrong if they don't follow the advice, or go another route. ... There is, after all, advice, and dogged persuasion. ...
    (alt.support.diabetes)
  • Re: ctrl + end
    ... > of your code for you than manipulate the rest. ... It will make your life ... Always good advice. ... I think I'll throw that into my boilerplate VBA ...
    (microsoft.public.vb.general.discussion)
  • Re: How to get the open file name?
    ... Thank you for your advice. ... so I can manipulate it from my code afterwards. ... > Hi Rola ...
    (microsoft.public.word.vba.general)
  • Re: DataGridView, Formatting a Numeric Column
    ... setting the Format after setting the Alignment. ... I'll be doing some more trashing about in the documentation and the ... further advice I'd be most grateful. ... (Not that the doc said "n" would provide right justification, ...
    (microsoft.public.dotnet.languages.vb.controls)