Results 1 to 2 of 2
Thread: Time-Zone JS
Hybrid View
-
8th November 2008 10:17 #1
Time-Zone JS
,
, . , -, . , , .
. , 1000 . . , .
!
:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<title>Time-Zone Clock</title>
<script>
function time (city, offset) {
d = new Date();
// converting to milliseconds, adding local time zone offset, getting UTC time in msec
utc = d.getTime() + (d.getTimezoneOffset() * 60000);
// creating new Date object for different city using supplied offset
nd = new Date(utc + (3600000*offset));
var hours = nd.getHours();
var minutes = nd.getMinutes();
var seconds = nd.getSeconds();
if (hours <=9) hours = "0" + hours;
if (minutes <=9) minutes = "0" + minutes;
if (seconds <=9) seconds = "0" + seconds;
return " " + city + " " + " " + ": " + hours + ":" + minutes + ":" + seconds;
}
//Sofia time
setInterval("time()", 1000)
document.write(time("", "+2"));
</script>
</head>
<body>
</body>
</html>|Asus P5K Premium WiFi|Intel C2D E6750|Kingston 2x1GB@667MHz|Seagate 250GB+500GB|Coolmax CP 500W|Asus EN 8800 GTS 320MB|
-
8th November 2008 14:01 #2
, , , .
. , , -.Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251" /> <title>Time-Zone Clock</title> <script> function time (city, offset) { d = new Date(); // converting to milliseconds, adding local time zone offset, getting UTC time in msec utc = d.getTime() + (d.getTimezoneOffset() * 60000); // creating new Date object for different city using supplied offset nd = new Date(utc + (3600000*offset)); var hours = nd.getHours(); var minutes = nd.getMinutes(); var seconds = nd.getSeconds(); if (hours <=9) hours = "0" + hours; if (minutes <=9) minutes = "0" + minutes; if (seconds <=9) seconds = "0" + seconds; document.getElementById("clockdiv").innerHTML = " " + city + " " + " " + ": " + hours + ":" + minutes + ":" + seconds; } function bodyload(){ setInterval("time(\"\", \"+2\")", 1000); } </script> </head> <body onload="bodyload()"> <div id="clockdiv"></div> </body> </html>Last edited by Bombera; 8th November 2008 at 14:07. Reason: alert :)
EVGA X299 FTW K|i9-7960X@4.7|4x8 Patriot Viper Steel 4000|GTX 1660 Ti|970 EVO 1 TB|Seasonic Focus GX-1000|Xigmatek Elysium|
Rampage IV Extreme BE|E5-1680v2@4.7|4x4 HyperX 1866|Cougar Aqua 240|GTX 1050 Ti|970 EVO 1/4 TB|CM 850 SilentPro|HAF-X|




Reply With Quote
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in