У меня есть следующий код, который используется для отображения имени текущего дня, за которым следует заданная фраза.
<script type="text/javascript">
<!--
// Array of day names
var dayNames = new Array(
"It Sunday, the weekend is nearly over",
"Yay! Another Monday",
"Hello Tuesday, at least you're not Monday",
"It Wednesday. Halfway through the week already",
"It Thursday.",
"It Friday - Hurray for the weekend",
"Saturday Night Fever");
var now = new Date();
document.write(dayNames[now.getDay()] + ".");
// -->
</script>
То, что я хотел бы сделать, это указать номер текущей недели в скобках после фразы. Я нашел следующий код:
Date.prototype.getWeek = function() {
var onejan = new Date(this.getFullYear(),0,1);
return Math.ceil((((this - onejan) / 86400000) + onejan.getDay()+1)/7);
}
Что было взято из http://javascript.about.com/library/blweekyear.htm, но я не знаю, как добавить его в существующий код javascript.