Javascript World Time Zone Display code _ Time Date

Source: Internet
Author: User

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead> <meta content=" text/html; Charset=utf-8 "http-equiv=" Content-type/> <title>javascript World time display </title> <meta name= "Author" content= "Geovin Du smear"/> </pead> <body> <p></p> <div id= "local" ></div> < Div id= "LOCALUTC" ></div> <div id= "Bombay" ></div> <div id= "Singapore" ></div> <div Id= "Tokyo" ></div> <div id= "London" ></div> <script language= "javascript" type= "text/" JavaScript ">//https://gist.github.com/1326893https://gist.github.com/1326893//20120511 geovin Du smear-poly function Calctime (city, offset) {var d = new Date (); UTC = D.gettime () + (D.gettimezoneoffset () * 60000); var nd = New Date (UTC + (3600000 * offset)); var gmttime = New Date (UTC) var day = nd. GetDate (); var month = Nd.getmonth (); var year = Nd.getyear (); var hr = nd.gethours (); + offset var min = nd.getminutes (); var sec = Nd.getseconds (); if (Year < 1000) {year + = 1900} var montharray = new Array ("January", "February", "March", "April", "may", "June", " July "," August "," September "," October "," November "," December ") var monthdays = new Array (" 31 "," 28 "," 31 "," 30 "," 31 ", "The", "the", "to", "", "", "", "", "" (year%4 = = 0) {monthdays = new Array ("31", "29", "31", "30", "31", "30", ")" "," "," "," "," "," "," "," "," "(year%100 = = 0 && year%400!= 0) {monthdays = new Array (" 31 "," 28 "," 31 ") , "1", "", "", "", "", "", "", "", "", "" "," "" "If" (hr >=) {hr = hr-24 day =-} if (HR < 0) { HR-= -24 Day-= 1} if (HR < ten) {hr = "+ hr} if (min <) {min =" 0 "+ min} if (sec <) {sec = "0" + sec} if (Day <= 0) {if (month = = 0) {month = one year-= 1} else{month = month-1} day = Monthdays[month]} if (Day > Monthdays[month]) {day = 1 if (month = one) {month = 0 year-= 1} else{Month -=-1}} return city+ ":" "+montharray[month" + "+ Day +", "+ year +" <br> "+ hr +": "+ min + ":" + sec//return "The local time in" + City + "is" + nd.tolocalestring () +; The function Worldclockzone () {document.getElementById (' local '). InnerHTML = "The local time is" + (new Date ()). Tolocalest Ring (); document.getElementById (' Localutc '). InnerHTML = "The local time is" + (new Date ()). toLocaleString (); document.getElementById (' Bombay '). InnerHTML = Calctime (' Bombay ', ' +5.5 '); document.getElementById (' Singapore '). InnerHTML = calctime (' Singapore ', ' +8 '); document.getElementById (' Tokyo '). InnerHTML = Calctime (' Tokyo ', ' +9 '); document.getElementById (' London '). InnerHTML =calctime (' London ', ' +1 '); SetTimeout ("Worldclockzone ()", 1000)} Window.onload=worldclockzone; </script> <pr/> <address></address> <!--Hhmts start--> modified:mon Oct 02:04:17 brst <!--hhmts end--> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.