My site is in german and i use moment and angular-moment for transaltion. Everything working fine except AM/PM. My code
<time>{{ messagedata.created*1000| amDateFormat: 'D, MMM YYYY, h:mm:ss A' }}</time>
Result: 16, Febr. 2017, 5:30:00 AM
Wanted Result: 16, Febr. 2017, 5:30:00 Uhr
Configuration
app.run(function ($rootScope, $location, amMoment, moment) {
amMoment.changeLocale(LANGCODE);
moment.updateLocale('en', {
relativeTime : {
m: "1 Minute",
h: "an Hour",
d: "1 Day",
M: "1 Month",
y: "1 Year",
}
});
moment.updateLocale('de', {
relativeTime : {
m: "1 Minute",
d: "1 Tag",
M: "1 Monat",
y: "1 Jahr",
}
});
});
So, I want to change AM/PM in german,Is it possible? How?
German time doesnt work/go with AM/PM. German time is in 24h format. Also the day date ends with an .
instead of an ,
. Finally the correct output would be: 16. Febr. 2017, 17:30:00 Uhr
. That's what we (germans) would expect as a correct date format :)
<time>{{ messagedata.created*1000| amDateFormat: 'D. MMM YYYY, HH:mm:ss' }} Uhr</time>
H, HH 24 hour time
h, or hh 12 hour time (use in conjunction with a or A)
24-hour time notation is used officially and for purposes that require precision like announcements in the media. In colloquial speech, a 12-hour clock is used.
Note colloquial speech != technical correct output.
If you still wand to use the A
placeholder you could create an own meridiem
replacement like:
// From 2.8.1 to 2.11.2
moment.locale('de', {
meridiem : function () {
return 'Uhr';
}
});
In that way the following format should work for you:
<time>{{ messagedata.created*1000| amDateFormat: 'D. MMM YYYY, HH:mm:ss A' }}</time>
An other solution could be handled with angular-translate
. Just create the correct meridiem
translation inside your translation files. This solution would look like:
<time>
{{ messagedata.created*1000| amDateFormat: 'D. MMM YYYY, HH:mm:ss' }}
<span translate="meridiem"></span>
</time>