Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Parse a date in RT format into RFC822
use DateTime;
my $date = '2009-02-13 15:43:14';
print "Original: $date\n";
print "Converted: ";
my ($year, $month, $day, $hour, $minutes, $seconds) =
($date=~ /(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/);
my $datetime = DateTime->new(
year => $year,
month => $month,
day => $day,
hour => $hour,
minute => $minutes,
second => $seconds,
time_zone => 'America/New_York',
print $datetime->strftime("%a, %d %b %Y %H:%M:%S %z");
print "\n";

This comment has been minimized.

Copy link
Owner Author

@evandhoffman evandhoffman commented Oct 27, 2011


Original: 2009-02-13 15:43:14
Converted: Fri, 13 Feb 2009 15:43:14 -0500

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment