I am trying to display some firebase timestamp in the template view, Unfortunately no luck with the angular datePipe.
<p>Seen {{user.updatedAt | date: 'yyyy/MM/dd h:mm:ss a'}}</p>
I do get this error:
ERROR Error: InvalidPipeArgument: 'Unable to convert "Timestamp(seconds=1528515928, nanoseconds=105000000)" into a date' for pipe 'DatePipe
To convert a Firestore date or timestamp to a JavaScript Date, we use firebase. firestore. Timestamp. fromDate to convert the a date to a Firestore timestamp.
The proper way to attach a timestamp to a database update is to attach a placeholder value in your request. In the example below Firebase will replace the createdAt property with a timestamp: firebaseRef = firebase. database().
firestore. Timestamp. 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. It is encoded using the Proleptic Gregorian Calendar which extends the Gregorian calendar backwards to year one.
You can either convert Timestamp to milliseconds or to Date:
<p>Seen {{user.updatedAt.toMillis() | date:'yyyy/MM/dd h:mm:ss a'}}</p>
or
<p>Seen {{user.updatedAt.toDate() | date:'yyyy/MM/dd h:mm:ss a'}}</p>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With