Time::y2038(3pm)

πŸ’– Time::y2038 β€” NAME ✨

okay so bestie, this page is for Time::y2038, which is literally just versions of Perl's time functions that still work past the year 2038 πŸŽ€ no cap.


πŸ¦‹ SYNOPSIS

use Time::y2038;

print scalar gmtime 2**52;  # Sat Dec  6 03:48:16 142715360

🌈 DESCRIPTION

So here's the tea πŸ“: on many computers, Perl's time functions just… stop working past the year 2038. Not a Perl problem exactly β€” it's a design fault in the underlying C libraries Perl leans on. Kinda iconic of them, lowkey tragic though. 😭

Time::y2038 hands you replacements for those functions that are accurate to +/1 142 million years ✨. That's the whole point. That's the moment.

heads up, bestie: this module only imports the functions into your namespace. If you want them swapped out everywhere, go look at Time::y2038::Everywhere πŸ‘‘

It replaces the following functions:

πŸ’… gmtime()

See "gmtime" in perlfunc for the deets.

πŸ’… localtime()

See "localtime" in perlfunc for the deets.

🫢 timegm()

my $time = timegm($sec, $min, $hour, $month_day, $month, $year);

The inverse of gmtime() β€” you feed it a date and it gives you back the coorsponding $time (number of seconds since Midnight, January 1st, 1970 GMT) ⏰. All the values work the same as gmtime(), so $month is 0..11 (January is 0) and the $year is years since 1900 (so 2008 is 108). mmkay?

# June 4, 1906 03:02:01 GMT
my $time = timegm(1, 2, 3, 4, 5, 6);

timegm() can also take two additional arguments which are always ignored πŸ™ˆ. Why? So you can yeet the results from gmtime() straight back into timegm() without having to strip the extra args off first. Convenient, right?

The following is always true:

timegm(gmtime($time)) == $time;

🧚 timelocal()

my $time = timelocal($sec, $min, $hour, $mday, $month, $year);
my $time = timelocal($sec, $min, $hour, $mday, $month, $year, $wday, $yday, $isdst);

Like timegm(), except it interprets the date in the current time zone 🌍.

timelocal() will normally figure out on its own whether daylight savings time is in effect β€” but if you hand it $isdst, that overrides the check πŸ‘€. This is mostly useful for resolving those ambiguous times around "fall back", when the hour between 1am and 2am literally happens twice. Time is a scam fr fr.

# Sun Nov  4 00:59:59 2007
print timelocal(59, 59, 0, 4, 10, 107);  # 1194163199

# Sun Nov  4 01:00:00 2007 DST, one second later
print timelocal(0, 0, 1, 4, 10, 107, undef, undef, 1);  # 1194163200

# Sun Nov  4 01:00:00 2007 no DST, one hour later
print timelocal(0, 0, 1, 4, 10, 107, undef, undef, 0);  # 1194166800

$wday and $yday are ignored πŸ’€. They're only there so it stays compatible with what localtime() gives you back.


⚠️ LIMITATIONS ⚠️

The safe range of times is +/ 2**52 β€” that's about 142 million years 🌌.

Even though the underlying time library can handle times from -263 to 263-1 (roughly +/- 292 billion years πŸ‘€), Perl uses floating point numbers internally, so accuracy degrates after 2**52. Yeah. That's the tradeoff, bestie. 😭


πŸ› BUGS & FEEDBACK πŸ›

Wanna report a bug or lurk on the existing ones? Go here:

http://rt.cpan.org/Dist/Display.html?Queue=Time-y2038

If you like the module, pleeeease drop the author an email 🫢 he will be so happy.

The latest version of this module lives at http://y2038.googlecode.com/, and the repository is at http://y2038.googlecode.com/svn/trunk/ in perl/Time-y2038. Heads up: you have to check out the whole repository, because there are symlinks in there πŸŒ€ β€” you can't just grab the one directory, it's giving "trust the process".


πŸ‘‘ AUTHOR πŸ‘‘

Michael G Schwern <schwern@pobox.com> πŸ’œ


Copyright 2008-2010 Michael G Schwern

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself ✨.

See http://www.perl.com/perl/misc/Artistic.html


πŸ” SEE ALSO πŸ”


and that's the whole page bestie πŸ’– this was perl v5.42.3, dated 2026-08-19, serving Time::y2038(3pm) realness. go forth and be y2038-proof πŸ¦‹βœ¨ periodt πŸ’…

πŸ“¦ where this page comes from