ZonedDateTime class
A moment in time viewed at a fixed UTC offset, such as +05:30.
Dart's DateTime only knows UTC and the device's local zone. This class adds "what time is it in another offset" without bundling the 400 KB IANA database. For named zones with daylight-saving rules, pass the offset you get from a tz package or your backend.
- Implemented types
Constructors
Properties
- day → int
-
Day at offset.
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- hour → int
-
Hour at offset.
no setter
- minute → int
-
Minute at offset.
no setter
- month → int
-
Month at offset.
no setter
- offset → Duration
-
Offset from UTC.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- utc → DateTime
-
The instant, in UTC.
final
- wallTime → DateTime
-
Wall-clock time at offset, as a UTC-flagged DateTime whose fields
read as local time in that offset (use it for display only).
no setter
- year → int
-
Year at offset.
no setter
Methods
-
add(
Duration duration) → ZonedDateTime -
Adds a fixed
duration. -
compareTo(
ZonedDateTime other) → int -
Compares this object to another object.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toIso8601String(
) → String -
ISO-8601 text with offset, e.g.
2026-10-20T09:00:00+05:30. -
toLocal(
) → DateTime - The same instant in the device's local zone.
-
toString(
) → String -
A string representation of this object.
override
-
withOffset(
Duration offset) → ZonedDateTime -
The same instant at another
offset.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
Static Methods
-
parseOffset(
String text) → Duration? -
Parses
+05:30,-0800,+02orZ. -
tryParse(
String input) → ZonedDateTime? -
Parses an ISO-8601 string with an offset, e.g.
2026-10-20T09:00:00+05:30or...Z.