Javascript Moment.js 在日期格式中间包含文本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28241002/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Moment.js Include text in middle of date format
提问by BlueCaret
I have a format of "Jan. 27, 2015 at 8:17 AM" that I need to display using moment.js. I'm using the format
我需要使用 moment.js 显示“2015 年 1 月 27 日上午 8:17”的格式。我正在使用格式
moment.format('MMM. D, YYYY at h:mm A z');
Everything works great except for the word "at". How can I get that word to display as a word instead of the "a" in "at" being translated to the "am/pm". Right now using that date format it ends up looking like this: Jan. 27, 2015 amt 8:17 AM. Notice the "amt" instead of "at".
除了“at”这个词外,一切都很好。我怎样才能让这个词显示为一个词,而不是“at”中的“a”被翻译成“am/pm”。现在使用该日期格式,它最终看起来像这样:2015 年 1 月 27 日上午 8:17。注意“amt”而不是“at”。
Is there any simple way of getting it to not process the "a" as part of the format? I have already tried splitting the output and manually entering the "at" after the third space but I'd like a cleaner code if possible.
有什么简单的方法可以让它不将“a”作为格式的一部分处理?我已经尝试拆分输出并在第三个空格后手动输入“at”,但如果可能的话,我想要一个更清晰的代码。

