Войти

Показать полную графическую версию : Яваскрипт... на дату и время


Denis Shutka
17-12-2004, 01:51
Подскажите повозможности Яваскрипт для показа времени и числа....
а также скрипт который в зависимости от времени суток выдавал надпись доброе утро утром, доброго дня днём..итд..

slaine
17-12-2004, 02:29
Ты прикалываешься?

a = new Date()
b = a.getDate()
document.write(""+b)

mrcnn
17-12-2004, 08:25
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.




© OSzone.net 2001-2012