# perldoc > Time::Local

---
type: CommandReference
command: Time::Local
mode: perldoc
section: 
source: perldoc
---

## Quick Reference
- `timelocal_posix($sec, $min, $hour, $mday, $mon, $year)` — Exact inverse of `localtime()`, returns seconds since epoch
- `timegm_posix($sec, $min, $hour, $mday, $mon, $year)` — Exact inverse of `gmtime()`, returns seconds since epoch
- `timelocal_modern($sec, $min, $hour, $mday, $mon, $year)` — Same as `timelocal()` but no year munging (year as-is)
- `timegm_modern($sec, $min, $hour, $mday, $mon, $year)` — Same as `timegm()` but no year munging
- `timelocal($sec, $min, $hour, $mday, $mon, $year)` — Default export, with year interpretation (see below)
- `timegm($sec, $min, $hour, $mday, $mon, $year)` — Default export, with year interpretation
- `timelocal_nocheck($sec, $min, $hour, $mday, $mon, $year)` — No range checking, must be imported
- `timegm_nocheck($sec, $min, $hour, $mday, $mon, $year)` — No range checking, must be imported

## Name
Time::Local - Efficiently compute time from local and GMT time

## Synopsis
perl
use Time::Local qw( timelocal_posix timegm_posix );

my $time = timelocal_posix( $sec, $min, $hour, $mday, $mon, $year );
my $time = timegm_posix( $sec, $min, $hour, $mday, $mon, $year );
Other importable functions: `timelocal_modern()`, `timegm_modern()`, `timelocal()`, `timegm()`, `timelocal_nocheck()`, `timegm_nocheck()`.

## Functions

- `timelocal_posix($sec, $min, $hour, $mday, $mon, $year)` — Exact inverse of `localtime()`. `$year` is offset from 1900. Performs range checking on `$sec`, `$min`, `$hour`, `$mday`, `$mon`. Croaks on invalid values.
- `timegm_posix($sec, $min, $hour, $mday, $mon, $year)` — Exact inverse of `gmtime()`. Same range checking.
- `timelocal_modern($sec, $min, $hour, $mday, $mon, $year)` — Like `timelocal_posix()` but takes year as provided (no 1900 offset). Range checking.
- `timegm_modern($sec, $min, $hour, $mday, $mon, $year)` — Like `timegm_posix()` but year as provided. Range checking.
- `timelocal($sec, $min, $hour, $mday, $mon, $year)` — Default export. Applies year interpretation (see below). Range checking.
- `timegm($sec, $min, $hour, $mday, $mon, $year)` — Default export. Same year interpretation.
- `timelocal_nocheck($sec, $min, $hour, $mday, $mon, $year)` — No range checking. Must be explicitly imported. ~3% faster.
- `timegm_nocheck($sec, $min, $hour, $mday, $mon, $year)` — No range checking. Must be explicitly imported.

### Year Value Interpretation

Applies only to `timelocal()` and `timegm()` (and their `nocheck` variants). The year is interpreted as:

- **> 999**: actual year (e.g., 1964)
- **100–999**: offset from 1900 (e.g., 112 = 2012)
- **0–99**: rolling "current century" (50 years on either side of current year). This changes as time passes, causing bugs.

### DST Handling

- **Ambiguous local times**: When a DST fall-back creates two GMT times, `timelocal()` returns the epoch for the earlier GMT time.
- **Non-existent local times**: When a DST spring-forward skips an hour, `timelocal()` returns the epoch for one hour later.

### Limits

- On Perl < 5.12.0: depends on `time_t` size (typically 32-bit, range ~Dec 1901 to Jan 2038). Croaks outside range.
- On Perl >= 5.12.0: safe range of at least +/- 2**52 seconds (~142 million years). Negative epochs fully supported.

## See Also

- [time(2) man page](https://man7.org/linux/man-pages/man2/time.2.html)
- [Perl built-in functions `localtime()` and `gmtime()`](https://perldoc.perl.org/functions/localtime)
- [Time::Local source repository](https://github.com/houseabsolute/Time-Local)