在Moments周中不起作用

时间:2018-08-20 09:36:19

标签: momentjs

我正在尝试使用momentjs从一年中获取每周的计数,如下所示,

示例1:运行良好

let now = moment("01/06/2018");
var weekresult = now.week();
alert(weekresult);

示例2:

var weekinYear = now.weeksInYear();
alert(weekinYear);

示例2:错误

Uncaught TypeError: now.weeksInYear is not a function

运行于Jsfiddle

1 个答案:

答案 0 :(得分:1)

正如docs所说,isoWeeksInYear()自版本UPDATE ot set ot.Delivered = dt.Delivered FROM OverallTable ot INNER JOIN DeliveredTable dt ON dt.Invoice = ot.Invoice AND dt.Product = ot.Product; 起可用,而您正在链接的提琴中使用时刻2.6.0+时。

此外,由于2.2.1既不符合ISO 8601也不符合RFC 2822,因此您必须使用moment(String, String)而不是moment(String)

以下是最新版本的实时示例:

"01/06/2018"
let now = moment("01/06/2018", "DD/MM/YYYY");
var weekresult = now.week();
console.log(weekresult);
var weekinYear = now.weeksInYear();
console.log(weekinYear);