I am using Moment js and Angular Moment js to calculate time ago for my website. Everything is working perfectly except one thing. I don't know whether is it possible or not. I checked their humanize() documentation but didn't find anything usefull.
<span am-time-ago="messagedata.created | amFromUnix"></span>
Result: a day ago
but i want 1 day ago
. Is it possible? If yes how?
I am using Moment js and Angular Moment js to calculate time ago for my website. Everything is working perfectly except one thing. I don't know whether is it possible or not. I checked their humanize() documentation but didn't find anything usefull.
<span am-time-ago="messagedata.created | amFromUnix"></span>
Result: a day ago
but i want 1 day ago
. Is it possible? If yes how?
2 Answers
Reset to default 4Check fromnow section from moment it is what you are looking for, since you want to display the date with respect to today.
Those messages depend on the locale used by moment.js but you can update the locale to provide a different version of the messages
moment.updateLocale('en', {
relativeTime : {
future: "in %s",
past: "%s ago",
s: "seconds",
m: "a minute",
mm: "%d minutes",
h: "an hour",
hh: "%d hours",
d: "a day",
dd: "%d days",
M: "a month",
MM: "%d months",
y: "a year",
yy: "%d years"
}
});
with the angular directive, you should be able to configure the moment instance when the application starts
var myapp = angular.module('myapp', ['angularMoment']);
myapp.run(function(amMoment) {
amMoment.changeLocale(...);
});
you can check the moment.js documentation about customisation for more details
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745400751a4626088.html
评论列表(0条)