Компьютерный форум OSzone.net  

Компьютерный форум OSzone.net (http://forum.oszone.net/index.php)
-   Вебмастеру (http://forum.oszone.net/forumdisplay.php?f=22)
-   -   Яваскрипт... на дату и время (http://forum.oszone.net/showthread.php?t=42601)

Denis Shutka 17-12-2004 01:51 280789

Яваскрипт... на дату и время
 
Подскажите повозможности Яваскрипт для показа времени и числа....
а также скрипт который в зависимости от времени суток выдавал надпись доброе утро утром, доброго дня днём..итд..

slaine 17-12-2004 02:29 280803

Ты прикалываешься?

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

mrcnn 17-12-2004 08:25 280853

Цитата:

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.


Время: 10:18.

Время: 10:18.
© OSzone.net 2001-