Epoch & Unix Timestamp in Perl

Get the current epoch timestamp

my $epoch_seconds = time();

Convert epoch to date

my @utc = gmtime(1718200000);
my $str = scalar gmtime(1718200000);

Convert date to epoch

use Time::Local qw(timegm);
my $epoch = timegm(0, 0, 0, 12, 5, 2026);

Perl notes

timegm takes (sec, min, hour, mday, month, year) with a 0-based month — June is 5. Time::HiRes provides sub-second precision.

Check any value live with the epoch converter, or read what Unix time actually counts.

Other languages

C · C# · C++ · Dart · Go · Java · JavaScript · Kotlin · MySQL · PHP · PostgreSQL · Python · R · Ruby · Rust · Scala · SQLite · Swift · TypeScript