Timestamp.fromDate constructor

Timestamp.fromDate(
  1. DateTime date
)

Creates a new timestamp from the given date.

final documentRef = firestore.doc('col/doc');

final date = Date.parse('01 Jan 2000 00:00:00 GMT');
documentRef.set({ 'startTime': Timestamp.fromDate(date) });

  • date: The date to initialize the Timestamp from.

Returns a new Timestamp representing the same point in time as the given date.

Implementation

factory Timestamp.fromDate(DateTime date) {
  return Timestamp.fromMillis(date.millisecondsSinceEpoch);
}