jQuery(document).ready( function($){
var newDate = new Date( 2016 , 2 , 28 , 8 , 0 , 0 , 0 );
alert( $.fn.jquery );
$('#countdown-ex1').countdown({until: newDate});
});
结果:
其中
var newDate = new Date( 2016 , 1 , 28 , 8 , 0 , 0 , 0 );
结果:
jQuery版本:1.11.3
TL; DR;
第2个月等于3月
第1个月等于2月
现在这是一个错误还是故意的? 为什么会故意这样做?
答案 0 :(得分:0)
月值基于零,即。 0
= Jan,1
= 2月,依此类推。要获得您期望的日期,只需将Month值减少1:
jQuery(document).ready( function($){
var newDate = new Date( 2016 , 1 , 28 , 8 , 0 , 0 , 0 ); // 28 Feb 2016
alert( $.fn.jquery );
$('#countdown-ex1').countdown({until: newDate});
});
答案 1 :(得分:0)
答案 2 :(得分:-1)
日期的月份是0基数。 http://www.w3schools.com/jsref/jsref_getmonth.asp
getMonth()方法根据当地时间返回指定日期的月份(从0到11)。