且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jQuery PickMeUp datepicker:禁用日期数组

更新时间:2022-05-04 22:33:17

好的,写下来:

valueOf() Date 对象,获取日期中的毫秒数(自01/01/1970以来)。

valueOf() is one of the methods of Date object that gets the number of milliseconds in a date (since 01/01/1970).

indexOf() Array 对象,用于检查元素是否是数组的成员。

indexOf() is a method of the Array object that checks if an element is a member of an array.

所以你的第一个代码是现在,你也得到了调整:

So your first code is spot on, also you got the tweaks:

var arDates = [new Date("2014-02-14").valueOf(),new Date("2014-02-11").valueOf(),new Date("2014-02-09").valueOf()];

disabled: arDates.indexOf(date.valueOf()) != -1

可能面对的是时区的问题。例如: new Date(2014-02-17)对于我来说,在2月17日并没有创建日期。由于我的时区,它下降了3个小时。

What you may face is issues with timezones. For instance: new Date("2014-02-17") for me does not create a date in Feb 17th. It falls back 3 hours due to my timezone.