[Omaha.pm] Perl - Print current date as UTC(Zulu)

Jay Hannah jay at jays.net
Fri Aug 1 19:39:33 PDT 2008


On Aug 1, 2008, at 9:37 AM, Tony Simons wrote:
> I'm having difficulty figuring out how to converting the current  
> date to Zulu
> Output date example:
> 20080731T212151Z  Any example that could take in a common input  
> date. example:
>
> Fri, 01 Aug 2008 09:35:39 CDT

Looks like this is working. Hope it helps,

j


# perl -MCPAN -e 'install Class::Date'
# perl -MCPAN -e 'install Date::Parse'


$ cat j.pl
#!/usr/bin/perl -w

use strict;
use Class::Date qw(localdate -DateParse);
use Date::Parse;

my $in_date = localdate(str2time($ARGV[0]));
my $out_date = $in_date->to_tz('GMT');

$Class::Date::DATE_FORMAT="%Y%m%dT%H%M%SZ";
print "$out_date\n";


$ perl j.pl "Fri, 01 Aug 2008 09:35:39 CDT"
20080801T143539Z



More information about the Omaha-pm mailing list