How to parse ISO8601 compliant strings to perl's DateTime object?

Viewed 2252

My final objective is to compare the current date and time with that returned by a TVMaze API that's in ISO8601 format, to determine if a new TV show has been aired.

use strict;
use warnings;
use feature 'say';
use DateTime;
my $curmytime = DateTime->now()->format_cldr("yyyy-MM-dd'T'HH:mm:ssZ");
# Output is: Time now in UTC:2017-07-17T10:44:52+0000
say "Time now in UTC:". $curmytime;
my $strtobeparsed = '2017-04-09T21:00:00-0400';
# Next, parse the string "2017-04-09T21:00:00-0400" to a DateTime object

How do I parse the string to a DateTime object?

1 Answers
Related