I have date-time strings in the below format
[yyyymmddhhmmss+TZ] "20110711114445+08", "20110711114445+05.30".
How should i find out which is most recent date-time string ? I want all of the string to convert into a single time-zone and then convert the strings into integer to find out ma开发者_运维问答ximum integer. Help me out ?
You can use DateTime::Format::Strptime
to parse the date-time strings into DateTime
objects. Once you have the objects, you can compare them as ordinary integers.
use DateTime::Format::Strptime;
use List::Util 'max';
my $Strp = new DateTime::Format::Strptime(pattern => '%Y%m%d%H%M%S%z');
my @objects = map $Strp->parse_datetime($_), @strings;
my $dt = max(@objects);
The Date::Calc can help you.
精彩评论