DateTime.fromMillisecondsSinceEpoch constructor

DateTime.fromMillisecondsSinceEpoch(
  1. int millisecondsSinceEpoch, {
  2. bool isUtc = false,
})

Constructs a new DateTime instance with the given millisecondsSinceEpoch.

If isUtc is false then the date is in the local time zone.

The constructed DateTime represents 1970-01-01T00:00:00Z + millisecondsSinceEpoch ms in the given time zone (local or UTC).

final newYearsDay =
    DateTime.fromMillisecondsSinceEpoch(1641031200000, isUtc:true);
print(newYearsDay); // 2022-01-01 10:00:00.000Z

Implementation

external DateTime.fromMillisecondsSinceEpoch(
  int millisecondsSinceEpoch, {
  bool isUtc = false,
});