javascript 如何使用momentjs从日期中获取当天的名称
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27830335/
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
How to get name of the day from date with momentjs
提问by IanWatson
I am using momentjs
and want to output the name of the day ie. "Wednesday" but the API only seems to offer a number.
我正在使用momentjs
并想输出当天的名称,即。“星期三”,但 API 似乎只提供了一个数字。
Is there a way to do this without hard-coding it to a particular language?
有没有办法在不将其硬编码为特定语言的情况下做到这一点?
回答by James Donnelly
From the Format section of their documentation:
Day of Week
dddd
Sunday Monday ... Friday Saturday
本周日
dddd
星期日星期一......星期五星期六
moment().format('dddd');