문제

When creating a moment date object using the following settings:

var date = moment({
    year:   2014,
    month:  2,
    day:    17,
    hour:   9,
    minute: 60
});
date.isValid(); // false

Mon Mar 17 2014 10:00:00 GMT+0100 (Romance Standard Time)

The output is correct but when I try to validate this date, it is incorrect. I think it's because the mintues are greater than 60. Normally this would not be a problem but i'm using Twix to create ranges and due to this problem i'm getting invalid dates. Is there any way to fix this issue?

도움이 되었습니까?

해결책

You may use the native Date constructor to deal with overflows for you :

var date = moment(new Date(2014,2,17,9,60));
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top