Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Показать сообщение отдельно

Ветеран


Сообщения: 1404
Благодарности: 135

Профиль | Отправить PM | Цитировать


Цитата:
a = new Date()
b = a.getDate()
document.write(""+b)
Этот скрипт выдает только текущее число ;-)

Более интересный пример:


Код: Выделить весь код
<script language="JavaScript"><!--  
//Скрипт отмечает точную дату и время вашего прибытия на страницу
	document.write("<br><br><font color='black'>Используем методы getMonth, getDate, getFullYear, getHours, getMinuts, getSeconds</font>")
	Now = new Date();var m=Now.getMonth();m=m+1;document.write("<br><br><font color='#B0D5E8'>Сегодня" + " "+ Now.getDate()+ "-" + m + "-" + Now.getFullYear() + ". Вы зашли на мою страницу ровно в: " + Now.getHours() + " часов " + Now.getMinutes() + "минут  и " + Now.getSeconds() + " секунд.");

var hour=Now.getHours();
if (hour>=12 && hour <17)
{ alert ("Доброго дня");}
if (hour>=17 && hour <24)
{ alert ("Доброго вечера");}
if (hour>=0 && hour <12)
{ alert ("Доброго утра");}

// -->
</script>
Методы для работы с временем:
getDate method -- Returns the day of the month for the specified date.
getDay method -- Returns the day of the week for the specified date.
getHours method -- Returns the hour for the specified date.
getMinutes method -- Returns the minutes in the specified date.
getMonth method -- Returns the month in the specified date
getSeconds method -- Returns the seconds in the current time.
getYear method -- Returns the year in the specified date.

Отправлено: 08:25, 17-12-2004 | #3