[ create a new paste ] login | about

Link: http://codepad.org/berle9um    [ raw code | output | fork ]

Perl, pasted on Nov 22:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
sub my_format_to_iso8601 {
    $_[0] =~ /(\d\d):(\d\d):(\d\d), (\d\d)\/(\d\d)\/(\d\d\d\d)/;
    return "$6-$4-$5T$1:$2:$3";
}

$date1 = "11:56:41, 11/22/2011";
$date2 = "11:20:41, 11/20/2011";
$d1 = my_format_to_iso8601($date1);
$d2 = my_format_to_iso8601($date2);
print "first is $d1\n";
print "second is $d2\n";
if($d2 < $d1) {
    print "second is earlier\n";
} else {
    print "first is earlier\n";
}


Output:
1
2
3
first is 2011-11-22T11:56:41
second is 2011-11-20T11:20:41
first is earlier


Create a new paste based on this one


Comments: