Current epoch — epochtime.tools · A precision instrument for time

Get the current Unix timestamp

final millis = DateTime.now().millisecondsSinceEpoch;
final seconds = millis ~/ 1000;
final micros = DateTime.now().microsecondsSinceEpoch;  // on the web this can lose precision far from the epoch

Convert a Unix timestamp to a date

final utc = DateTime.fromMillisecondsSinceEpoch(1700000000 * 1000, isUtc: true);
// 2023-11-14 22:13:20.000Z
final local = DateTime.fromMillisecondsSinceEpoch(1700000000123);   // device zone

Convert a date to a Unix timestamp

final s = DateTime.utc(2026, 11, 14, 10).millisecondsSinceEpoch ~/ 1000;  // 1794650400
final parsed = DateTime.parse('2026-11-14T15:30:00+05:30');
final s2 = parsed.millisecondsSinceEpoch ~/ 1000;                        // 1794650400

Timezones

// Core Dart has no named zones. Use package:timezone for IANA IDs:
import 'package:timezone/data/latest.dart' as tzdata;
import 'package:timezone/timezone.dart' as tz;

tzdata.initializeTimeZones();
final ny = tz.TZDateTime.fromMillisecondsSinceEpoch(tz.getLocation('America/New_York'), 1700000000000);

Common mistakes

  • fromMillisecondsSinceEpoch returns local time unless you pass isUtc: true.
  • DateTime.parse without an offset gives a local time. Add Z or an offset when the string is UTC.
  • On the web, microsecondsSinceEpoch can be rounded for dates far from 1970. The Dart documentation gives roughly 1685 to 2254 as the range where it stays exact.

Complete example

void main() {
  final now = DateTime.now().millisecondsSinceEpoch ~/ 1000;
  print('Now: $now');
  final t = DateTime.fromMillisecondsSinceEpoch(1700000000 * 1000, isUtc: true);
  print('UTC: ${t.toIso8601String()}');
}

Check any value with the epoch converter, or convert a whole column with the batch converter. All examples use 1700000000 (2023-11-14 22:13:20 UTC) and 1794650400 (2026-11-14 10:00:00 UTC).

Official documentation

Last updated: