Format Date time in AngularJS

后端 未结 13 1787
Happy的楠姐
Happy的楠姐 2020-11-30 22:00

How do I properly display the date and time in AngularJS?

The output below shows both the input and the output, with and without the AngularJS date filter:



        
13条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-30 22:35

    Your code should work as you have it see this fiddle.

    You'll have to make sure your v.Dt is a proper Date object for it to work though.

    {{dt | date:'yyyy-MM-dd HH:mm:ss Z'}}
    

    or if dateFormat is defined in scope as dateFormat = 'yyyy-MM-dd HH:mm:ss Z':

    {{dt | date:dateFormat }}
    

提交回复
热议问题