Epoch & Unix Timestamp in Dart

Get the current epoch timestamp

final epochSeconds = DateTime.now().millisecondsSinceEpoch ~/ 1000;

Convert epoch to date

final dt = DateTime.fromMillisecondsSinceEpoch(1718200000 * 1000, isUtc: true);

Convert date to epoch

final epoch = DateTime.utc(2026, 6, 12).millisecondsSinceEpoch ~/ 1000;

Dart notes

Dart's native unit is milliseconds (microsecondsSinceEpoch is also available). Pass isUtc: true when reconstructing — the default interprets in local time.

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

Other languages

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