最佳答案
我有一个字符串作为 Mon 03-Jul-2017, 11:00 AM/PM
,我必须使用矩 js 将它转换成类似于 11:00 AM/PM
的字符串。
这里的问题是,我无法从日期时间字符串获得 AM
或 PM
。
我正在做的是:
moment(Mon 03-Jul-2017, 11:00 AM, 'dd-mm-yyyy hh:mm').format('hh:mm A')
它工作得很好,因为我得到了 11:00 AM
,但是如果字符串中有 PM
,它仍然在输出中给出 AM
。
像这样,moment(Mon 03-Jul-2017, 11:00 PM, 'dd-mm-yyyy hh:mm').format('hh:mm A')
在输出中也给 11:00 AM
而不是 11:00 PM