Проблем с js 2009 -3909

bojko91

Registered
Здравейте. Имам един скрипт който отговаря за пускането на час, дата ден и година. Под ФФ всичко си е ок , но под Ие годината не е 2009 а 3909 ? на какво може да се дължи това?
 
jooorooo каза:
да код :-) има място с добавяне на 1900 години, но не се прави проверка.

Ето кода

Код:
<script type="text/javascript">function clock() {
		now = new Date();
		hours = now.getHours();
		minutes = now.getMinutes();
		seconds = now.getSeconds();
		now_time = "" + hours;
		now_time += ((minutes < 10) ? ":0" : ":") + minutes;
		now_time += ((seconds < 10) ? ":0" : ":") + seconds;
		date = now.getDate();
		month = now.getMonth();
		switch (month) {
		case 0:
		month = "Януари";
		break;
		case 1:
		month = "Февруари";
		break;
		case 2:
		month = "Март";
		break;
		case 3:
		month = "Април";
		break;
		case 4:
		month = "Май";
		break;
		case 5:
		month = "Юни";
		break;
		case 6:
		month = "Юли";
		break;
		case 7:
		month = "Август";
		break;
		case 8:
		month = "Септември";
		break;
		case 9:
		month = "Октомври";
		break;
		case 10:
		month = "Ноември";
		break;
		case 11:
		month = "Декември";
		break;
		}
		year = now.getYear();
		den = now.getDay();
		switch (den) {
		case 0:
		den = "Неделя";
		break;
		case 1:
		den = "Понеделник";
		break;
		case 2:
		den = "Вторник";
		break;
		case 3:
		den = "Сряда";
		break;
		case 4:
		den = "Четвъртък";
		break;
		case 5:
		den = "Петък";
		break;
		case 6:
		den = "Събота";
		break;
		}
		year = now.getYear()+1900 ;
		now_date = + date + " " + month + " " + year;
		document.getElementById("clock_show").innerHTML = "<font face=Verdana size=2>" + now_date + ", " + now_time + "</font>";
		setTimeout("clock()", 1000);
		}
</script>

Може ли да се поправи?
 

<script type="text/javascript">function clock() {
now = new Date();
hours = now.getHours();
minutes = now.getMinutes();
seconds = now.getSeconds();
now_time = "" + hours;
now_time += ((minutes < 10) ? ":0" : ":") + minutes;
now_time += ((seconds < 10) ? ":0" : ":") + seconds;
date = now.getDate();
month = now.getMonth();
switch (month) {
case 0:
month = "Януари";
break;
case 1:
month = "Февруари";
break;
case 2:
month = "Март";
break;
case 3:
month = "Април";
break;
case 4:
month = "Май";
break;
case 5:
month = "Юни";
break;
case 6:
month = "Юли";
break;
case 7:
month = "Август";
break;
case 8:
month = "Септември";
break;
case 9:
month = "Октомври";
break;
case 10:
month = "Ноември";
break;
case 11:
month = "Декември";
break;
}
year = now.getYear();
den = now.getDay();
switch (den) {
case 0:
den = "Неделя";
break;
case 1:
den = "Понеделник";
break;
case 2:
den = "Вторник";
break;
case 3:
den = "Сряда";
break;
case 4:
den = "Четвъртък";
break;
case 5:
den = "Петък";
break;
case 6:
den = "Събота";
break;
}
year = now.getYear();
if(year < 2000) {
year = year +1900; }
now_date = + date + " " + month + " " + year;
document.getElementById("clock_show").innerHTML = "<font face=Verdana size=2>" + now_date + ", " + now_time + "</font>";
setTimeout("clock()", 1000);
}
</script>
 
raiden каза:

<script type="text/javascript">function clock() {

year = now.getYear();
if(year < 2000) {
year = year +1900; }
now_date = + date + " " + month + " " + year;
document.getElementById("clock_show").innerHTML = "<font face=Verdana size=2>" + now_date + ", " + now_time + "</font>";
setTimeout("clock()", 1000);
}


Оправи се +1
 

Back
Горе