First tried
import { Timestamp } from '@firebase/firestore-types';
and then how to create a Timestamp object?
var now: Timestamp = ???
var now: Timestamp = Timestamp.now() //Module not found: Error: Can't resolve '@firebase/firestore-types'
First tried
import { Timestamp } from '@firebase/firestore-types';
and then how to create a Timestamp object?
var now: Timestamp = ???
var now: Timestamp = Timestamp.now() //Module not found: Error: Can't resolve '@firebase/firestore-types'
import { Timestamp } from '@firebase/firestore-types';
Here Timestamp is just a type, if you want to get the current time just use
var now = new Date(;
JS Date objects do get saved as timestamps in Firestore/firebase:
ref.update({ updatedAt: new Date() })
// results in timestamp in Firestore
Using serverTimestamp() method to update the Timestamp object
import {serverTimestamp } from 'firebase/firestore';
ref.update({ updatedAt: serverTimestamp() })
// results in timestamp in Firestore
Don't use Timestamp from firestore-types. The one you can use is available in firestore.
Use
import { Timestamp } from "@firebase/firestore";
instead of
import { Timestamp } from "@firebase/firestore-types";
Then you can use: Timestamp.fromDate(new Date());
© 2022 - 2024 — McMap. All rights reserved.