Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Date format conversion

Reply
Thread Tools

Date format conversion

 
 
Robert
Guest
Posts: n/a
 
      05-30-2006
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

 
Reply With Quote
 
 
 
 
David Squire
Guest
Posts: n/a
 
      05-30-2006
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-F...1.02/Format.pm

CPAN is your friend.

DS
 
Reply With Quote
 
 
 
 
Mothra
Guest
Posts: n/a
 
      05-30-2006
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


 
Reply With Quote
 
Robert
Guest
Posts: n/a
 
      05-31-2006
Thank you for your answer!

Robert

 
Reply With Quote
 
David Squire
Guest
Posts: n/a
 
      05-31-2006
Robert wrote:
> Thank you for your answer!
>
> Robert
>


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

DS
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date format Conversion John Smith Java 5 02-23-2006 10:46 AM
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM
Date Format - best way of converting a string into a date format Brian Candy ASP .Net 2 02-18-2004 02:13 PM
Calling date conversion function before binding the date to a daragrid Sanjeeb ASP .Net Web Controls 2 01-26-2004 06:36 AM
Given a date, how to find the beginning date and ending date of that week Matt ASP .Net 1 11-08-2003 09:14 PM



Advertisments