[英]Moment.js returning unexpected year
I'm struggling with the new year 2017 in my web app using moment.js. 我正在使用moment.js在Web应用程序中度过2017年新的一年。
When I'm writing: 当我写的时候:
moment('2017-01-03').isoWeekYear(2016).week(52); // results = Dec 27 2015
meanwhile when i write: 同时我写的时候:
moment('2017-01-04').isoWeekYear(2016).week(52); //results = Dec 26 2016
My expectation is that both of these should give me the answer "Dec 26 2016". 我的期望是这两个都应该给我答案“ 2016年12月26日”。 Probably I'm thinking wrong or could this be a bug in moment.js? 可能是我想错了,或者这可能是moment.js中的错误?
I have struggled for a while to come up with an answer or a workaround without any success.. 我已经苦苦挣扎了一段时间,想出一个没有成功的答案或解决方法。
Are you using an up to date version of moment.js? 您是否正在使用moment.js的最新版本? Something is off, because here's what I get when I run your moment.js code: 发生了什么事,因为这是运行我的moment.js代码时得到的结果:
console.log(moment('2017-01-03').isoWeekYear(2016).week(52)); console.log(moment('2017-01-04').isoWeekYear(2016).week(52));
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.1/moment.min.js"></script>
"2016-12-20T05:00:00.000Z"
"2016-12-21T05:00:00.000Z"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.