[英]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
. 从您的注释看来,您是以String
而不是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' }}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.