Timestamp class

A Timestamp represents a point in time independent of any time zone or calendar, represented as seconds and fractions of seconds at nanosecond resolution in UTC Epoch time.

Timestamps are encoded using the Proleptic Gregorian Calendar, which extends the Gregorian calendar backwards to year one. Timestamps assume all minutes are 60 seconds long, i.e. leap seconds are 'smeared' so that no leap second table is needed for interpretation. Possible timestamp values range from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.

Implemented types


Timestamp(int seconds, int nanoseconds)
seconds is the number of seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive. [...]
Timestamp.fromDateTime(DateTime dateTime)
Creates a new Timestamp instance from the given date. [...]
Timestamp.fromMicrosecondsSinceEpoch(int microsecondsSinceEpoch)
Constructs a new Timestamp instance with the given microsecondsSinceEpoch.
Timestamp.fromMillisecondsSinceEpoch(int millisecondsSinceEpoch)
Constructs a new Timestamp instance with the given millisecondsSinceEpoch.
Constructs a Timestamp instance with current date and time. [...]


hashCode int
The hash code for this object. [...]
read-only, override
microsecondsSinceEpoch int
The number of microseconds since the 'Unix epoch' 1970-01-01T00:00:00Z (UTC).
millisecondsSinceEpoch int
The number of milliseconds since the 'Unix epoch' 1970-01-01T00:00:00Z (UTC).
nanoseconds int
nanoseconds is the non-negative fractions of a second at nanosecond resolution.
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
seconds int
seconds is the number of seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z.


compareTo(Timestamp other) int
Compares this object to another object. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
toDateTime({bool isUtc}) DateTime
Convert a Timestamp to a DateTime object. This conversion causes a loss of precision and support millisecond precision.
toIso8601String() String
Returns an ISO-8601 full-precision extended format representation. The format is yyyy-MM-ddTHH:mm:ss.mmmuuunnnZ nanoseconds and microseconds are omitted if null
toString() String
A string representation of this object. [...]


operator ==(Object other) bool
The equality operator. [...]

Static Methods

parse(String text) Timestamp
The function parses a subset of ISO 8601 which includes the subset accepted by RFC 3339. [...]
tryAnyAsTimestamp(dynamic any) Timestamp
Try to get a Timestamp from either a DateTime, a Timestamp, a text or an int (ms since epoch)
tryParse(String text) Timestamp
parse or returns null