1 2 #!/usr/bin/perl -w 3 4 use strict; 5 use POSIX qw(strftime); 6 7 my $now = time(); 8 9 # We need to munge the timezone indicator to add a colon between the hour and minute part 10 my $tz = strftime("%z", localtime($now)); 11 $tz =~ s/(\d{2})(\d{2})/$1:$2/; 12 13 # ISO8601 14 print strftime("%Y-%m-%dT%H:%M:%S", localtime($now)) . $tz . "\n"; 15 # RFC822 (actually RFC2822, as the year has 4 digits) 16 print strftime("%a, %d %b %Y %H:%M:%S %z", localtime($now)) . "\n";
You need to create an account or log in to post comments to this site.