DateTime object represents a specific instant in time, expressed as a date and time of day in the Gregorian calendar. Internally, it stores the number of microseconds that have elapsed since the Unix epoch (00:00:00 UTC on January 1, 1970).
Instantiation
TheDateTime class provides several constructors to initialize instances based on specific calendar components, existing timestamps, or ISO 8601 strings.
Time Zone Handling
DartDateTime instances are anchored to one of two time zones:
- UTC: Coordinated Universal Time.
- Local: The time zone configured on the host system.
America/New_York) without external libraries.
Component Access
Read-only properties allow access to individual calendar components.Immutability and Arithmetic
DateTime objects are immutable. Operations that modify the time return a new DateTime instance. Time deltas are represented by the Duration class.
Comparison
The class implementsComparable, allowing for direct comparison of temporal order.
Platform Precision
The precision ofDateTime depends on the underlying platform:
- Dart Native (VM/AOT): Supports microsecond precision (64-bit integer).
- Dart Web (JavaScript): Supports millisecond precision (due to the limitations of the JavaScript
Dateobject). Microsecond values will be truncated to milliseconds.
String Representation
Dart provides standard methods for serializing the object to string formats.Master Dart with Deep Grasping Methodology!Learn More





