convert time stamp to Date inside angular expression like {{new Date(timestamp)}}

后端 未结 6 1588
旧时难觅i
旧时难觅i 2021-02-05 11:49

Today I found that\'s it\'s not working to convert for a date inside angular expression.

So I just making something like

{{new Date(elem.times         


        
6条回答
  •  鱼传尺愫
    2021-02-05 12:02

    When the timestamp is in milliseconds: Only Date:

    {{elem.timestamp | date: 'yyyy-MM-dd'}}
    

    Date & Time:

    {{elem.timestamp | date: 'yyyy/MM/dd hh:mm:ss a'}}
    

    Date & Time(24-hr format):

    {{elem.timestamp | date: 'yyyy/MM/dd HH:mm:ss'}}
    

    When your timestamp is in seconds, then just multiply with 1000:

    {{elem.timestamp*1000 | date: 'yyyy/MM/dd HH:mm:ss'}}
    

提交回复
热议问题