ZonedDateTime.now constructor

ZonedDateTime.now([
  1. Timezone? timezone
])

Creates a ZonedDateTime that represents the current date-time in the timezone.

The platform's current timezone is used if timezone is not given.

By default, retrieving the platform's timezone is only only supported on Windows, MacOS, Linux & web. The Factory timezone will be returned on all other platforms. See Timezone.platformTimezoneProvider.

Implementation

factory ZonedDateTime.now([Timezone? timezone]) {
  timezone ??= Timezone.now();
  final now = DateTime.now().microsecondsSinceEpoch;
  return ZonedDateTime._(timezone, timezone.span(at: now), now);
}