Skip to content

Instantly share code, notes, and snippets.

@aanoaa
Created October 17, 2012 09:19
Show Gist options
  • Save aanoaa/3904636 to your computer and use it in GitHub Desktop.
Save aanoaa/3904636 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use DateTime::Format::ISO8601;
my $str = '15:36:08 UTC Fri Oct 12 2012';
my @date = split / /, $str;
my %MMAP = (
Oct => '10',
);
my %TMAP = (
UTC => 'Z',
KST => '+09',
);
$date[0] =~ s/://g;
my $newStr = sprintf "%s%s%sT%s%s", $date[5], $MMAP{$date[3]}, $date[4], $date[0], $TMAP{$date[1]};
print "$newStr\n";
my $dt = DateTime::Format::ISO8601->parse_datetime($newStr);
print $dt->ymd, "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment