Epoch & Unix Timestamp in PHP
Get the current epoch timestamp
$epochSeconds = time(); Convert epoch to date
$dt = new DateTimeImmutable('@1718200000'); Convert date to epoch
$epoch = (new DateTimeImmutable('2026-06-12T00:00:00Z'))->getTimestamp(); PHP notes
The '@timestamp' constructor always yields UTC regardless of the default timezone setting. microtime(true) returns float seconds with microsecond 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 · Perl · PostgreSQL · Python · R · Ruby · Rust · Scala · SQLite · Swift · TypeScript