I have to handle two locales for en and fr and display formatted hours depending on locale.
I try to do this :
const hour = moment({
hour: 15
}).format('LT');
It display 15:00 for fr and 3:00pm for en . I want 15h for fr format and 3 pm for en.
I tried to use the updateLocale method to add specific options, with LT format, but I can't arrive at the result.
const optionsFR = {
longDateFormat: {
LT: 'HH:mm',
},
meridiem: (): string => 'h',
}
const optionsEn = {
longDateFormat: {
LT: 'h:mm a',
},
meridiem: (): string => 'h',
}
moment.updateLocale(locale, options);
I could modify the LT option to do LT: h a
for en and LT: HH
for fr. but I can't display 'h' unit for fr-fr. Do I have to do it manually?
from format LT moment with am / pm / h unit depending on locale
No comments:
Post a Comment