I\'m trying to get the timestamp of a document that I created in firestore, but what I get is this:
myService.ts
getDomiciliari
Thanks to @Renaud who put emphasis on where I was implementing the timestamp, it should be when creating a record in Firestore. In my case I am working with a formGroup, then the code would look something like this:
forma: FormGroup;
constructor( fb: FormBuilder) {
this.forma = fb.group ({
field1: [ ''],
field2: [ ''],
...
myDate: [ firebase.firestore.FieldValue.serverTimestamp() ],
});
}
This alternative also works but remember that it is the current time of the client's computer (user's browser).
forma: FormGroup;
constructor( fb: FormBuilder) {
this.forma = fb.group ({
field1: [ ''],
field2: [ ''],
...
myDate: [ new Date() ],
});
}