According to the information provided in the documentation, using amCalendar
:
You can format dates using the calendar()
method from moment.js.
To customize the output of moment's calendar
, you can utilize the moment.updateLocale
function. By default, moment displays values like '[Today at] LT'
, '[Tomorrow at] LT'
, but if you need something different such as '[Today at] HH:mm'
, you can adjust it accordingly.
Below is a functional example:
angular.module('MyApp',['angularMoment'])
.run(function(){
moment.updateLocale('en', {
calendar : {
lastDay : '[Yesterday at] HH:mm',
sameDay : '[Today at] HH:mm',
nextDay : '[Tomorrow at] HH:mm',
lastWeek : '[last] dddd [at] HH:mm',
nextWeek : 'dddd [at] HH:mm',
sameElse : 'L'
}
});
})
.controller('AppCtrl', function($scope) {
$scope.message = {};
$scope.message.time = moment().add(7, 'h');
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.9/angular.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.1/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-moment/1.0.1/angular-moment.min.js"></script>
<div ng-app="MyApp" ng-controller="AppCtrl">
<span>{{message.time | amCalendar}}</span>
</div>