Javascript 时区倒计时脚本,未按预期工作?

Javascript 时区倒计时脚本,未按预期工作?,javascript,timezone,Javascript,Timezone,我正在寻找一个时区可调的javascript倒计时,发现了这个名为tzcount.js的脚本。根据说明: 月份可以指定为介于1和12之间的数字,以表示 您将在一年中的哪个月进行倒计时() 如果今年的月份已经过去,则为下一年) 但是当我为month输入值1时,脚本告诉我日期已经过去,而不是假设它是下一年的第一个月。我是否遗漏了什么,或者这个脚本是否没有按预期工作 全文如下: <!--Copy and paste just above the close </BODY> of yo

我正在寻找一个时区可调的javascript倒计时,发现了这个名为tzcount.js的脚本。根据说明:

月份可以指定为介于1和12之间的数字,以表示 您将在一年中的哪个月进行倒计时() 如果今年的月份已经过去,则为下一年

但是当我为month输入值1时,脚本告诉我日期已经过去,而不是假设它是下一年的第一个月。我是否遗漏了什么,或者这个脚本是否没有按预期工作

全文如下:

<!--Copy and paste just above the close </BODY> of you HTML webpage.-->

<SCRIPT type="text/javascript">

// ****  Time Zone Count Down Javascript  **** //
/*
Visit http://rainbow.arch.scriptmania.com/scripts/
 for this script and many more
*/

////////// CONFIGURE THE COUNTDOWN SCRIPT HERE //////////////////

var month = '*';     //  '*' for next month, '0' for this month or 1 through 12 for the month 
var day = '1';       //  Offset for day of month day or + day  
var hour = 0;        //  0 through 23 for the hours of the day
var tz = -5;         //  Offset for your timezone in hours from UTC
var lab = 'tzcd';    //  The id of the page entry where the timezone countdown is to show

function start() {displayTZCountDown(setTZCountDown(month,day,hour,tz),lab);}

    // **    The start function can be changed if required   **
window.onload = start;

////////// DO NOT EDIT PAST THIS LINE //////////////////

function setTZCountDown(month,day,hour,tz) 
{
var toDate = new Date();
if (month == '*')toDate.setMonth(toDate.getMonth() + 1);
else if (month > 0) 
{ 
if (month <= toDate.getMonth())toDate.setYear(toDate.getYear() + 1);
toDate.setMonth(month-1);
}
if (day.substr(0,1) == '+') 
{var day1 = parseInt(day.substr(1));
toDate.setDate(toDate.getDate()+day1);
} 
else{toDate.setDate(day);
}
toDate.setHours(hour);
toDate.setMinutes(0-(tz*60));
toDate.setSeconds(0);
var fromDate = new Date();
fromDate.setMinutes(fromDate.getMinutes() + fromDate.getTimezoneOffset());
var diffDate = new Date(0);
diffDate.setMilliseconds(toDate - fromDate);
return Math.floor(diffDate.valueOf()/1000);
}
function displayTZCountDown(countdown,tzcd) 
{
if (countdown < 0) document.getElementById(tzcd).innerHTML = "Sorry, you are too late."; 
else {var secs = countdown % 60; 
if (secs < 10) secs = '0'+secs;
var countdown1 = (countdown - secs) / 60;
var mins = countdown1 % 60; 
if (mins < 10) mins = '0'+mins;
countdown1 = (countdown1 - mins) / 60;
var hours = countdown1 % 24;
var days = (countdown1 - hours) / 24;
document.getElementById(tzcd).innerHTML = days + " day" + (days == 1 ? '' : 's') + ' + ' +hours+ 'h : ' +mins+ 'm : '+secs+'s';
setTimeout('displayTZCountDown('+(countdown-1)+',\''+tzcd+'\');',999);
}
}
</SCRIPT>
<p><font face="arial" size="-2">The countdown script at </font><br><font face="arial, helvetica" size="-2"><a href="http://rainbow.arch.scriptmania.com/scripts/">Rainbow Arch</a></font></p>

//****时区倒计时Javascript****//
/*
参观http://rainbow.arch.scriptmania.com/scripts/
对于这个脚本和更多
*/
//////////在此配置倒计时脚本//////////////////
变量月份='*';/'*'对于下个月,本月为“0”,或本月为1到12
变量日='1';//月日或+日的抵销
var小时=0;//一天中的小时数为0到23
var tz=-5;//从UTC到时区的偏移量(小时)
var lab='tzcd';//显示时区倒计时的页面条目的id
函数start(){displayTZCountDown(setTZCountDown(月、日、小时、日)、实验室);}
//**如果需要,可以更改启动功能**
window.onload=开始;
//////////请勿编辑超过此行的内容//////////////////
功能设置tz倒计时(月、日、小时、tz)
{
var toDate=新日期();
如果(month=='*')toDate.setMonth(toDate.getMonth()+1);
如果(月份>0),则执行其他操作
{ 

如果(月脚本工作不正常

您需要编辑此行:

if (month <= toDate.getMonth())toDate.setYear(toDate.getYear() + 1);
if(月)