admin管理员组文章数量:1181479
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
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
3 Answers
Reset to default 23Here is the 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
本文标签: javascriptFormat Date and time into 24 hours formatStack Overflow
版权声明:本文标题:javascript - Format Date and time into 24 hours format - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738237601a2070769.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论