[英]Format Date and time into 24 hours format
I am creating a app using angularjs.Here is my code: 我正在使用angularjs.创建一个应用程序。这是我的代码:
$scope.from = $filter('date')(new Date(), 'yyyy-MM-dd hh:mm');
It shows me output like: 2016-05-15 06:30
But I want to show like: 2016-05-15 18:30
它显示我输出如:
2016-05-15 06:30
但我想表现出: 2016-05-15 18:30
这是API https://docs.angularjs.org/api/ng/filter/date :
'yyyy-MM-dd HH:mm'
Following formats work : 以下格式工作:
Non-Padded: 非填充:
If you were to use non padded format like 6:30 or 8:30 then go for 'H' 如果您使用非填充格式,如6:30或8:30,那么请选择'H'
<div>{{ date_expression | date : 'yyyy-MM-dd H:mm'}}</div> <!-- in HTML -->
$filter('date')(new Date(), 'yyyy-MM-dd H:mm'); //in Controller
Padded: 加厚:
If you were to use padded format like 06:30 or 08:30 then go for 'HH' 如果您使用像06:30或08:30这样的填充格式,那么请选择'HH'
<div>{{ date_expression | date : 'yyyy-MM-dd HH:mm'}}</div> <!-- in HTML -->
$filter('date')(new Date(), 'yyyy-MM-dd HH:mm'); //in Controller
For Further Reference: 进一步参考:
https://docs.angularjs.org/api/ng/filter/date https://docs.angularjs.org/api/ng/filter/date
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.