Re: Date format conversion



Robert wrote:
Hello,

I want to convert a date string "2006-05-30T07:01:00Z" in to the
format "Tue, 30 May 2006 11:48:00 GMT". How to do this? A short &
simple solution would be great!

Thanks for your help,

Robert

This should help get you started

use strict;
use warnings;
use DateTime;
use DateTime::Format::Strptime;
use DateTime::Format::ISO8601;

my $Strp = new DateTime::Format::Strptime(
pattern => '%a, %d %b %Y %H:%M:%S %Z'
);

print $Strp->format_datetime(
DateTime::Format::ISO8601->parse_datetime('2006-05-30T07:01:00Z') );

D:\scripts>me.pl
Tue, 30 May 2006 07:01:00 UTC
D:\scripts>

Note:
GMT notation is outdated and should no longer be used

Hope this helps

Mothra


.



Relevant Pages

  • Help with formatting output with Text::Table
    ... I need some help formatting text output using Text table. ... use strict; ... use warnings; ... use DateTime; ...
    (comp.lang.perl.misc)
  • Re[2]: apache log parsing
    ... >> I want to split the datetime of apache log ... > use strict; use warnings; ... i am trying to do subsrt the datetime, hosts, etc. ...
    (perl.beginners)
  • Re: calcule date
    ... > use strict; ... I see you are using DateTime :-) you could do something ... use warnings; ... use CGI; ...
    (comp.lang.perl.misc)
  • Re: use strict/warnings
    ... use strict; ... use warnings; ... Robert ...
    (perl.beginners)
  • Check syntax question...
    ... I turned on "strict" and ... "warnings" and I am not sure what to do about this warning: ... I am just a wee learner of Perl. ... Robert ...
    (comp.lang.perl.misc)