Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
@list=("10/30/2001 12:30:00 p.m",
"10/29/2001 12:40:00 p.m",
"10/29/2001 12:40:00 a.m",
"10/03/2001 10:30:00 p.m",
"10/14/2001 1:00:00 a.m",
"10/30/2001 11:00:00 p.m",
);
sub mysort() {
@field1 = split (/\s+/,$a); # split on whitespace
@date1 = split("/", $field1[0]); # split up date
$time1 = $field1[1];
$time1 =~ s/://g; # remove ':' from time
$ampm1 = $field1[2];
@field2 = split (/\s+/,$b);
@date2 = split("/", $field2[0]);
$ampm2 = $field2[2];
$time2 = $field2[1];
$time2 =~ s/://g;
# ascending sort on year, month, day, am/pm, time
$date1[2] <=> $date2[2] || $date1[0] <=> $date2[0] || $date1[1] <=> $date2[1] || $ampm2 cmp $ampm1 || $time1 <=> $time2;
}
@sorted = sort mysort @list;
#!/usr/local/bin/perl
use Time::Local;
$date = '10/30/2001 11:30:00 a.m';
print "OLD Date: $date\n";
# convert to 24 hour clock.
# if last item starts with 'p' and the 4th item is not '12',
# then add 12 to 4th item
my @date = split(/[\/ :]+/,$date);
if ($date[6] =~ /^p/i && $date[3] ne '12')
{ $date[3] = $date[3] + 12; }
$seconds = timelocal($date[5],$date[4],$date[3],$date[1],$date[0]-1,$date[2]);
print "Epoch Seconds: $seconds\n";
# check that it is correct.
$new_date = localtime($seconds);
print "NEW Date: $new_date\n";