How to find the Greenwich Mean time in Perl?
Posted by Joys of Programming on in Perl
Using localtime, you can find the local time. But to find the greenwich mean time also known as GMT, you must make use of the function gmt.
my $time = time(); my ($sec, $min, $hours, $mday, $month, $year, $wday, $yday, $isdst) = gmtime($time); my @day = qw (Sunday Monday Tuesday Wednesday Thursday Friday Saturday); my @month_name = qw (January February March April May June July August Spetember October November December); print $day[$wday], " ",$month_name[$month], " ",$mday," ", $hours,":",$min,":",$sec, " ",1900+$year," GMT\n"
which generates the following output
Monday November 23 14:29:32 2009 GMT
Comments:
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=c5a645ac-4aaa-471f-855c-ffa1a02cdd74)