GMT Time in Perl

The function gmtime() in Perl works just like localtime() function but the returned values are localized for the standard Greenwich time zone. When called in list context, $isdst, the last value returned by gmtime, is always 0. There is no Daylight Saving Time in GMT.

You should make a note on the fact that localtime() will return the current local time on the machine that runs the script and gmtime() will return the universal Greenwich Mean Time, or GMT (or UTC).

Try the following example to print the current date and time but on GMT scale −


 Live Demo

$datestring = gmtime();
print "GMT date and time $datestring\n";


When the above code is executed, it produces the following result −

GMT date and time Sat Feb 16 13:50:45 2013

Updated on: 29-Nov-2019


Kickstart Your Career

Get certified by completing the course

Get Started