---
# System prepended metadata

title: JavaScript 網頁動態顯示時間
tags: [實作功能]

---

# JavaScript 網頁動態顯示時間
###### tags: `實作功能`

## 結果 ( GIF 圖 )
![](https://i.imgur.com/YRpcpPd.gif)

---

## Script
```
<script>
    $(function () {
        ShowTime();
    })

    function ShowTime() {
        var NowDate = new Date();
        var d = NowDate.getDay();
        var dayNames = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
        document.getElementById('showbox').innerHTML = '目前時間：' + NowDate.toLocaleString("zh-tw", { hour12: false }) + '（' + dayNames[d] + '）';
        setTimeout('ShowTime()', 1000);
    }
</script>
```

---

## Html
```
<div class="container-fluid" style="min-height:100%">
    <div class="row">
        <div class="col-12 d-flex align-items-start justify-content-start" >
            <h3 id="showbox" class="rounded" style="background-color: blanchedalmond;"></h3>
        </div>
    </div>
</div>
```