angularangular-moment

How can i get the hours from ngx moment pipe?


I am having this prop

date = '2021-11-16T23:00Z';

when i apply pipes on string date

{{dat | amUtc | amLocal | amDateFormat:'L' }} 

i get in my HTML

11/16/2021

But i can't find a way where i will include the hours

https://www.npmjs.com/package/ngx-moment

So at the end i will have 11/16/2021 23:00

If it is AM for example '2021-11-16T08:00Z' then i need to get 1/16/2021 08:00


Solution

  • Angular have pipe for dates, and i think will solve your problem.

    Take a look on angular doc DatePipe: https://angular.io/api/common/DatePipe

    If i undestood well, you will do like this:

    Component:

    date = '2021-11-16T23:00Z';
    

    HTML:

    {{date | date:'m/DD/yyyy hh:mm'}}
    

    The result will be:

    1/16/2021 08:00