RFC822 and ISO8601 date formats in Perl
#!/usr/bin/perl -w use strict; use POSIX qw(strftime); my $now = time(); # We need to munge the timezone indicator to add a colon between the hour and minute part my $tz = strftime("%z", localtime($now)); $tz =~ s/(\d{2})(\d{2})/$1:$2/; # ISO8601 print strftime("%Y-%m-%dT%H:%M:%S", localtime($now)) . $tz . "\n"; # RFC822 (actually RFC2822, as the year has 4 digits) print strftime("%a, %d %b %Y %H:%M:%S %z", localtime($now)) . "\n";