Reputation: 499
How can I convert a DateTime stamp to a DateTime object?
DateTime string: 2015-05-25T03:47:44
Is there a way to instantiate a DateTime object with this timestamp? If not, what's the best way to create a DateTime object with it?
Upvotes: 1
Views: 286
Reputation: 35198
use DateTime::Format::ISO8601
:
#!/usr/bin/env perl
use strict;
use warnings;
use DateTime::Format::ISO8601;
my $str = '2015-05-25T03:47:44';
my $dt = DateTime::Format::ISO8601->parse_datetime( $str );
print "$dt\n";
Upvotes: 3