Reputation: 65870
I use ngx-moment library. I need to format a datetime like so Mar 12 at 11 PM
I have tried like so:
.html
<p>{{invitedEvent.startDatetime | amDateFormat: 'MMM DD'}} at {{invitedEvent.startDatetime | amDateFormat: 'hh A'}}</p>
But it gives this error:
Invalid date at Invalid date
Here I use Firestore timestamp
DateTime like so:
Above library is working fine if I use like so <p>{{'24/01/2014' | amParse:'DD/MM/YYYY' | amDateFormat: 'MMM DD'}}</p>
But what value should I pass here amParse
?
Upvotes: 1
Views: 1229
Reputation: 1
Moment works with timestamp and format ISO 8601, change your timestamp format in Firestore.
Upvotes: 0
Reputation: 65870
This works for me.
<p>{{invitedEvent.startDatetime.toDate() | amDateFormat: 'MMM DD'}} at
{{invitedEvent.startDatetime.toDate() | amDateFormat: 'h:mm A'}}</p>
Note: I have used .toDate()
and Changed startDatetime:string
to startDatetime: Timestamp;
i.e. import { Timestamp } from '@firebase/firestore-types';
Upvotes: 2