I am creating a app using angularjs.Here is my code:
$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
这是API https://docs.angularjs.org/api/ng/filter/date :
'yyyy-MM-dd HH:mm'
Us it like this : $filter('date')(new Date(), 'yyyy-MM-dd HH:mm');
check jsfiddle here
Following formats work :
Non-Padded:
If you were to use non padded format like 6:30 or 8:30 then go for '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'
<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
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.