简体   繁体   中英

Angular js date filter “yyyy-mm-dd hh:mm:ss” to “MMM d, yyyy h mm”

I have a date like this

2019-02-15 16:01:18

and i am trying to show this in following format:

 Feb 2, 2019 4:01 PM

How can i achive this with date filter: here is what i tried:

{{ myDate | date:'MMM  d, yyyy hh:mm' }}

From your comments it appears you are starting with a String , not a Date .

var dateString = "2019-02-15 16:01:18";
$scope.myDate = new Date(dateString);

Then you can use the date filter as you have tried:

{{ myDate | date:'MMM  d, yyyy hh:mm' }}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM