格式化Moment.js am / pm以包含句点/点

问题描述:

我正在遇到一个小的格式化问题与时刻的 a 输入。

I'm running into a small formatting issue with moment's a input.

a / A将返回上午/上午PM /下午,但是有没有办法格式化以包括期间?

a/A will return AM/am PM/pm but is there a way to format this to include periods?

IE a.m。 pm 这是对客户端重要的格式更改,我无法使用时间文档找到修复程序。

I.E. a.m. p.m. it's a format change that is important to the client and I haven't been able to find the fix with moment's documentation

我尝试过



I've tried

moment.updateLocale('en', {
    meridiem : {
        am : 'a.m.',
        AM : 'A.M.',
        pm : 'p.m.',
        PM : 'P.M.'
    }
}); 

没有成功

是否可能?

您用于自定义meridiem的方法适用于版本< 1.6.0。您应该在较新版本中提供更新meridiem的功能。请参阅文档了解更多信息:

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.';
    }
  }
});