Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: convert month number to month name

by 2teez (Priest)
on Aug 30, 2012 at 07:08 UTC ( #990661=note: print w/ replies, xml ) Need Help??


in reply to convert month number to month name

Hi,

Hash is up to the rescue

my %month_name; @month_name{ 0 .. 11 } = qw(Jan Feb Mar Apr May Jun Jul Aug Sept Oct N +ov Dec); my ( $day, $month, $year ) = (localtime)[ 3, 4, 5 ]; $year = $year + 1900; print join " ", $day, $month_name{$month}, $year;
output
30 Aug 2012


Comment on Re: convert month number to month name
Select or Download Code
Re^2: convert month number to month name
by dsheroh (Parson) on Aug 30, 2012 at 09:59 UTC
    I'm not seeing the point of using a hash here... Since the hash keys are a contiguous, zero-based range of integers, why not just use an array instead of making a hash behave like one?
    my @month_name = qw(Jan Feb Mar Apr May Jun Jul Aug Sept Oct Nov Dec); my ( $day, $month, $year ) = (localtime)[ 3, 4, 5 ]; $year = $year + 1900; print join " ", $day, $month_name[$month], $year;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://990661]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2014-08-29 17:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (283 votes), past polls