How can I reformat time 06:31:04 to display only hh:mm - 06:31
Have tried
$scope.date = '06:31:04';
<p ng-bind="date | date:'HH:mm'"></p>
but time not formatting
How should I make it, thanks
AngularJS date Filter The date filter formats a date to a specified format.
The best solution was to write a filter
angular.module('foo', [])
.filter('formatTime', function ($filter) {
return function (time, format) {
var parts = time.split(':');
var date = new Date(0, 0, 0, parts[0], parts[1], parts[2]);
return $filter('date')(date, format || 'h:mm');
};
});
{{ '06:31:04' | formatTime }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With