Date format conversion

Discussion in 'Perl Misc' started by Robert, May 30, 2006.

  1. Robert

    Robert Guest

    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
     
    Robert, May 30, 2006
    #1
    1. Advertising

  2. Robert

    David Squire Guest

    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!
    >


    Use the Time::Format module:
    http://search.cpan.org/~roode/Time-Format-1.02/Format.pm

    CPAN is your friend.

    DS
     
    David Squire, May 30, 2006
    #2
    1. Advertising

  3. Robert

    Mothra Guest

    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
     
    Mothra, May 31, 2006
    #3
  4. Robert

    Robert Guest

    Thank you for your answer!

    Robert
     
    Robert, May 31, 2006
    #4
  5. Robert

    David Squire Guest

    Robert wrote:
    > Thank you for your answer!
    >
    > Robert
    >


    Thank who for what answer? Please quote context and include
    attribution(s) when you reply.

    DS
     
    David Squire, May 31, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Candy
    Replies:
    2
    Views:
    1,205
    Janaka
    Feb 18, 2004
  2. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,366
    Michael Borgwardt
    May 30, 2004
  3. John Smith

    Date format Conversion

    John Smith, Feb 22, 2006, in forum: Java
    Replies:
    5
    Views:
    15,083
    tom fredriksen
    Feb 23, 2006
  4. Chu
    Replies:
    3
    Views:
    4,233
    Shawn
    Aug 15, 2006
  5. Sanjeeb
    Replies:
    2
    Views:
    201
Loading...

Share This Page