ZonedDateTime class Absolute times

A date and time in a specific time zone.

The time zone defaults to "UTC" and may be changed by setting defaultZoneId.

Implemented types
Annotations
  • @immutable

Constructors

ZonedDateTime(int year, [int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0, int nanosecond = 0])
Creates a ZonedDateTime from individual components in the default time zone specified by defaultZoneId.
factory
ZonedDateTime.fromDateTime(DateTime dateTime, [String? zoneId])
Converts a DateTime to a ZonedDateTime.
ZonedDateTime.fromInstant(HasInstant instant, [String? zoneId])
Constructs a ZonedDateTime from an Instant.
ZonedDateTime.fromUnix(Timespan unixTimestamp, [String? zoneId])
Creates a ZonedDateTime using a time since midnight, January 1, 1970 UTC.
ZonedDateTime.now([String? zoneId])
Creates a ZonedDateTime using the current time.
ZonedDateTime.parse(String isoString, [String? zoneId])
Parses a ZonedDateTime from an ISO-8601 formatted string.
factory
ZonedDateTime.withZoneId(String zoneId, int year, [int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0, int nanosecond = 0])
Creates a ZonedDateTime from individual components in a given time zone.
factory

Properties

asOffsetDateTime OffsetDateTime
Returns an equivalent OffsetDateTime with the same offset.
no setter
day int
The day starting at 1.
no setteroverride
hashCode int
The hash code for this object.
no setteroverride
hour int
The hour from 0 to 23.
no setteroverride
inLeapYear bool
Determines if this date falls in a leap year.
no setteroverride
isDst bool
If this is a daylight savings (or summer) time.
no setter
minute int
The minute from 0 to 59.
no setteroverride
month int
The month from 1 to 12.
no setteroverride
nanosecond int
The nanoseconds from 0 to 999,999,999.
no setteroverride
offset NamedZoneOffset
The offset from UTC.
final
ordinalDay int
The number of days since the beginning of the year.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
second int
The second from 0 to 59.
no setteroverride
timeZone String
The common designation for the time zone (e.g. UTC, PST, PDT, CET, CEST).
no setter
unixTimestamp Timespan
The amount of time since midnight, January 1, 1970 UTC.
no setteroverride
weekday Weekday
The day of the week.
no setteroverride
year int
The year.
no setteroverride
zoneId String
A string that uniquely identifies the time zone.
final

Methods

atOffset([ZoneOffset? offset]) OffsetDateTime
Converts this to an OffsetDateTime.
override
compareTo(HasInstant other) int
Compares this to another HasInstant.
inherited
format(DateFormat format) String
Formats this object using the given format.
inherited
inTimezone([String? zoneId]) ZonedDateTime
Converts this to a ZonedDateTime in the time zone given by zoneId.
inherited
minusPeriod(Period period) ZonedDateTime
Subtracts a Period.
minusTimespan(Timespan timespan) ZonedDateTime
Subtracts a Timespan.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
periodUntil(HasDate date) Period
Finds the Period between this and another HasDate.
plusPeriod(Period period) ZonedDateTime
Adds a Period.
plusTimespan(Timespan timespan) ZonedDateTime
Adds a Timespan.
quantize(RelativeTime amount) ZonedDateTime
Rounds this to a value divisible by amount.
replace({int? year, int? month, int? day, int? hour, int? minute, int? second, int? nanosecond, String? zoneId}) ZonedDateTime
Returns a new datetime with one or more fields replaced.
timespanUntil(HasInstant other) Timespan
Finds the amount of time between this and another instant in time.
inherited
toDateTime() DateTime
Converts this to a standard Dart DateTime in the local time zone.
toInstant() Instant
Converts this to an Instant in UTC.
toLocal() LocalDateTime
Converts this to a LocalDateTime.
toString() String
Returns this as an ISO 8601-formatted string with an offset.
override

Operators

operator +(RelativeTime amount) ZonedDateTime
Adds a Timespan or Period.
operator -(RelativeTime amount) ZonedDateTime
Subtracts a Timespan or Period.
operator <(HasInstant other) bool
Less than operator.
inherited
operator <=(HasInstant other) bool
Less than or equals operator.
inherited
operator ==(Object other) bool
The equality operator.
override
operator >(HasInstant other) bool
Greater than operator.
inherited
operator >=(HasInstant other) bool
Greater than or equals operator.
inherited

Constants

maximum → const ZonedDateTime
The latest possible datetime.
minimum → const ZonedDateTime
The earliest possible datetime.