显示4个不同国家的当前时间

时间:2019-02-22 17:08:55

标签: javascript html

我希望有人能够帮助我看看我在这里做错了什么。 我愿意学习完全停留在这一部分。

我正在尝试为姐姐的商店构建一个简单的Intranet页面。 她想做的一件事是显示4个不同国家/地区的当前时间:我正为此而努力。

我在网上找到了“时间js”代码,并尝试在网格中使用它,但到目前为止,它所做的只是显示文本。在我需要它的地方显示时间。

请您帮我取消选择吗?

我正在使用Brackets,这是今天早上的最新版本(从早上8点开始使用)

在此先感谢您的帮助

var tday = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
var tmonth = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];

function GetClockUK() {
  var d = new Date();
  var nday = d.getDay(),
    nmonth = d.getMonth(),
    ndate = d.getDate(),
    nyear = d.getFullYear();
  var nhour = d.getHours(),
    nmin = d.getMinutes(),
    nsec = d.getSeconds(),
    ap;

  if (nhour == 0) {
    ap = " AM";
    nhour = 12;
  } else if (nhour < 12) {
    ap = " AM";
  } else if (nhour == 12) {
    ap = " PM";
  } else if (nhour > 12) {
    ap = " PM";
    nhour -= 12;
  }

  if (nmin <= 9) nmin = "0" + nmin;
  if (nsec <= 9) nsec = "0" + nsec;

  var clocktext = "" + tday[nday] + "  " + tmonth[nmonth] + "  " + ndate + ",  " + nyear + " " + nhour + ":" + nmin + ":" + nsec + ap + "";
  document.getElementsByClassName('item4').innerHTML = clocktext;
}
GetClockUK();
setInterval(GetClockUK, 1000);
<head>
  <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
</head>

<body style="background-color:black;">
  <li style="list-style: none;">

    <div class="grid-container">
      <div class="item1"> <img src="/images/NatTlImage.PNG" alt="Nat" width="95%" height="100%"></div>
      <div class="item2"> <img src="/images/NatShad4cm.png" alt="Logo" width="60%" height="100%"></div>
      <div class="item3"><img src="/images/UnionJack.png" alt="UK" width="255px" height="128px"></div>

      <div class="item4">GetClockUK();</div>
      <div class="item5"><img src="/images/wesmd.jpg" width="264px" height="135px"></div>
      <div class="item6"><img src="/images/RMTlg.png" width="264px" height="135px"></div>
      <div class="item7"><img src="/images/ColFlag.png" width="255px" height="128px"></div>
      <div class="item8">
        <a>
          <script>
            GetClockCo();
          </script>
        </a>
      </div>
      <div class="item9">colwrate</div>
      <div class="item10">
        <ul>
          <li><img src="/images/Dandal.PNG" alt="Dav" width="40%" height="70%"> = 4,000.00 CPO <br>
          </li>
          <li>- - - - - - - - - - - - - - - - - - - - - - <br>
          </li>
          <li>
            <img src="/images/BanCol.png" alt="BanCol" width="100px" height="30px">= 4,000.00 CPO
          </li>
        </ul>
      </div>
      <div class="item11"><img src="/images/EcuFlag.png" alt="Ecu" width="255px" height="128px"></div>
      <div class="item12">
        <a>
          <script>
            GetClockEcu();
          </script>
        </a>
      </div>
      <div class="item13">ecuwrate</div>
      <div class="item14">ecurrate</div>
      <div class="item15"><img src="/images/spain.png" alt="Spa" width="255px" height="128px"></div>
      <div class="item16">
        <a>
          <script>
            GetClockSpa();
          </script>
        </a>
      </div>
      <div class="item17">spawrate</div>
      <div class="item18">sparrate</div>
    </div>
</body>

0 个答案:

没有答案