Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

gmtime

Converts a Unix timestamp to UTC (Greenwich Mean Time), returning the same structure as localtime but without timezone or DST adjustments.

Identical to localtime in interface, but all values are in UTC rather than the local timezone. The $isdst field is always 0. If called without an argument, uses the current time.

The implementation uses a pure-Rust UTC calculation (no libc dependency), correctly handling negative timestamps (dates before the epoch) and leap years.

Synopsis

my @t = gmtime(0);     # (0,0,0,1,0,70,4,0,0) - epoch in UTC
my $s = gmtime(0);     # "Thu Jan  1 00:00:00 1970"
my @t = gmtime();      # current time in UTC

See Also

localtime, time, POSIX::strftime