我有以下
JavaScript代码,但由于某些原因,时间不包括分钟数:
var austDay = $("#<%= hiddenFieldTime.ClientID %>").val().split(" "); var year = austDay[0]; var months = austDay[1]; var days = austDay[2]; var time = austDay[3]; var timeUntil = new Date(parseInt(year),parseInt(months),parseInt(days),parseInt(time));
当我调试使用firebug这些是我的价值:
$("#ctl00_hiddenFieldTime").val() = "2011,5,6,14:20:00" year = "2011," months = "5," days = "6," time = "14:20:00" timeUntil = Date {Mon Jun 06 2011 14:00:00 GMT-0400 (Eastern Daylight Time)}
你可以看到,timeUntil设置为14:00:00而不是14:20:00
解决方法
parseInt(时间)是问题
这里是几个日期的初始化格式
var d = new Date(); var d = new Date(milliseconds); var d = new Date(dateString); var d = new Date(year,month,day,hours,minutes,seconds,milliseconds);