Click here to get back home

Date format

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Date format cc96ai 07-23-2008
|--> Re: Date format Gunnar Hjalmars...07-23-2008
Get Chitika Premium
Posted by cc96ai on July 23, 2008, 6:34 pm
Please log in for more thread options
I want to change the date format in perl script

input: "2005-11-01"
output:November 1, 2005

thanks

Posted by Gunnar Hjalmarsson on July 23, 2008, 7:44 pm
Please log in for more thread options
cc96ai wrote:
> I want to change the date format in perl script
>
> input: "2005-11-01"
> output:November 1, 2005

The POSIX::strftime() function may be helpful.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Posted by Carl on July 23, 2008, 8:01 pm
Please log in for more thread options

> I want to change the date format in perl script
>
> input: "2005-11-01"
> output:November 1, 2005
>
> thanks

You might be interested in the Date::Simple module:

--example--
$ cat test.pl
#!/usr/bin/perl

use strict;
use warnings;

use Date::Simple qw/date/;

my $d = date('2005-11-01');
print $d->format('%B %d, %Y'), "\n";

__END__

$ ./test.pl
November 01, 2005
$
--end example--

See:
http://search.cpan.org/dist/Date-Simple/lib/Date/Simple.pm

Hope that helps,
Carl.

Posted by Telemachus on July 24, 2008, 9:05 am
Please log in for more thread options
> I want to change the date format in perl script
>
> input: "2005-11-01"
> output:November 1, 2005
>
> thanks

Please don't post an identical question simultaneously to this group and
the Perl Beginners list.

Thanks.

Posted by cartercc on July 25, 2008, 1:57 pm
Please log in for more thread options
> I want to change the date format in perl script
>
> input: "2005-11-01"
> output:November 1, 2005
>
> thanks

If you want to roll your own, do this:

%months = (
1 => "January",
2 => "February",
3 => "March",
etc )

@input = split /-/, $input;
printf "%s $d, $d", $months, $input[2], $input[0];

CC

Similar ThreadsPosted
date format October 18, 2004, 9:43 am
date format July 5, 2006, 3:08 am
The best way to parse a date in a known format August 29, 2004, 12:29 am
Date format in perl September 9, 2004, 10:02 am
Date format conversion May 30, 2006, 9:37 am
how to change the date format of all my htmls? June 7, 2008, 11:31 pm
what is a good/fast way to format date string? March 6, 2006, 1:58 pm
howto Date Time string from MYSQL to German Format October 21, 2007, 6:58 am
Date Manipulation: Week_Number back to Date February 1, 2005, 7:20 pm
converting exponential format number to decimal format number December 14, 2006, 5:32 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap