I\'m running into a small formatting issue with moment\'s a
input.
a/A will return AM/am PM/pm but is there a way to format this to include periods?
<
Following moment docs you can have the following:
moment.updateLocale('en', {
meridiem: function (hour, minute, isLowercase) {
if( hour >= 12 )
return isLowercase ? 'p.m.' : 'P.M.';
else
return isLowercase ? 'a.m.' : 'A.M.';
}
});
console.log(moment().hour(1).format('HH:mm a'));
console.log(moment().hour(15).format('HH:mm A'));
As stated in the documentation, from moment version 1.6.0
Locale#meridiem
should be a callback function that returns the correct string based on hour, minute, and upper/lowercase.
While on version before 1.6.0:
Locale#meridiem
was a map of upper and lowercase versions of am/pm.