Format Moment.js am/pm to include periods/dots

前端 未结 4 1116
再見小時候
再見小時候 2021-01-25 13:56

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?

<
4条回答
  •  迷失自我
    2021-01-25 14:23

    The method you used to customize the meridiem applies to versions < 1.6.0. You should provide a function in newer versions to update meridiem. Please see the docs for more info:

    moment.updateLocale('en', {
      meridiem: function(hour, minute, isLowerCase) {
        if (hour < 12) {
          return 'a.m.';
        } else {
          return 'p.m.';
        }
      }
    });
    

提交回复
热议问题