[РАБОТНИЧЕК ]

ISO 8601.
06.06.2009, 20:44
Отображение даты и времени в соответствии с стандартом ISO 8601.
-----------------------------------------------------------------
Пример использования скрипта:


-----------------------------------------------------------------
Код скрипта:

Вставьте между тегами <HEAD></HEAD>


<SCRIPT LANGUAGE="JavaScript">

<!-- COLOPHON -->
<!--  -->
<!-- TITLE -->
<!-- TempersFewGit v 2.1 (ISO 8601 Time/Date script)  -->
<!--  -->
<!-- OBJECTIVE -->
<!-- Javascript script to detect the time zone where a browser -->
<!-- is and display the date and time in accordance with the  -->
<!-- ISO 8601 standard. -->
<!--  -->
<!-- AUTHOR -->
<!-- John Walker  -->
<!-- http://321WebLiftOff.net -->
<!-- jfwalker@ureach.com -->
<!--  -->
<!-- ENCOMIUM -->
<!-- Thanks to Stephen Pugh for his help. -->
<!--  -->
<!-- CREATED -->
<!-- 2000-09-15T09:42:53+01:00  -->
<!--  -->
<!-- REFERENCES -->
<!-- For more about ISO 8601 see: -->
<!-- http://www.w3.org/TR/NOTE-datetime -->
<!-- http://www.cl.cam.ac.uk/~mgk25/iso-time.html -->
<!--  -->
<!-- COPYRIGHT -->
<!-- This script is Copyright © 2000 JF Walker All Rights  -->
<!-- Reserved but may be freely used provided this colophon is  -->
<!-- included in full. -->
<!--  -->
<!-- ENDS -->


<!-- Begin
function isodatetime() {
var today = new Date();
var year  = today.getYear();
if (year < 2000)    // Y2K Fix, Isaac Powell
year = year + 1900; // http://onyx.idbsu.edu/~ipowell
var month = today.getMonth() + 1;
var day  = today.getDate();
var hour = today.getHours();
var hourUTC = today.getUTCHours();
var diff = hour - hourUTC;
var hourdifference = Math.abs(diff);
var minute = today.getMinutes();
var minuteUTC = today.getUTCMinutes();
var minutedifference;
var second = today.getSeconds();
var timezone;
if (minute != minuteUTC && minuteUTC < 30 && diff < 0) { hourdifference--; }
if (minute != minuteUTC && minuteUTC > 30 && diff > 0) { hourdifference--; }
if (minute != minuteUTC) {
minutedifference = ":30";
}
else {
minutedifference = ":00";
}
if (hourdifference < 10) {
timezone = "0" + hourdifference + minutedifference;
}
else {
timezone = "" + hourdifference + minutedifference;
}
if (diff < 0) {
timezone = "-" + timezone;
}
else {
timezone = "+" + timezone;
}
if (month <= 9) month = "0" + month;
if (day <= 9) day = "0" + day;
if (hour <= 9) hour = "0" + hour;
if (minute <= 9) minute = "0" + minute;
if (second <= 9) second = "0" + second;
time = year + "-" + month + "-" + day + "T"
+ hour + ":" + minute + ":" + second + timezone;
document.isoclock.display.value = time;
window.setTimeout("isodatetime();", 500);
}
//  End -->
</script>


Вставьте в параметр INTО Вашего тега BODY

<BODY OnLoad="isodatetime()">

Вставьте следующий код между тегами <BODY> </BODY>

<form name=isoclock>
<input type=text name=display size=30 style="border:0;">
</form>


Категория: Время \ Часы | Добавил: Администратор | Теги: java script, даты, ISO 8601, дата
Просмотров: 429 | Загрузок: 0 | Рейтинг: 0.0/0
Всего комментариев: 0
Добавлять комментарии могут только зарегистрированные пользователи.
[ Регистрация | Вход ]