使用 MomentJS 将 YYYY:MM:DD 字符串转换为星期几?

Using MomentJS to turn a YYYY:MM:DD string to a day of week?

所以我在项目中使用 MomentJS,需要将表示日期的字符串转换或解析为一周中的实际日期。

例如,

我需要 2015-07-24 到 return 一个星期五或代表星期五的数字。

目前,我在阅读 moment 文档时迷路了,不确定它是否可以做我想做的事情。

看来您只需要

var day = moment("1995-12-25").day(); // for the number
day = moment("1995-12-25").format('dddd')); // for the word

从这里开始:http://momentjs.com/docs/#/get-set/day/ and http://momentjs.com/docs/#/displaying/

你最终会学会阅读文档:)

这是您要找的吗?

时刻('2015-07-24').格式('dddd');

http://momentjs.com/docs/#/displaying/format/