js顯示動態時間的方法

2021-08-06 03:41:32 字數 2243 閱讀 8316

js顯示動態時間的方法

date物件的方法

date 物件的方法並不是靜態的,但是在使用時卻可以應用於所指定的單獨實體。

date 物件的方法簡介:

·getdate            |  根據本地時間獲取當前日期(本月的幾號)

·getday             |  根據本地時間獲取今天是星期幾(0-sunday,1-monday...)

·getfullyear        |  根據本地時間獲取當前年份(四位數字)

·gethours           |  根據本地時間獲取當前小時數(24小時制,0-23)

·getmilliseconds    |  根據本地時間獲取當前毫秒數

·getminutes         |  根據本地時間獲取當前分鐘數

·getmonth           |  根據本地時間獲取當前月份(注意從0開始:0-jan,1-feb...)

·getseconds         |  根據本地時間獲取當前秒數

·gettime            |  獲取utc格式的從1970.1.1 0:00以來的毫秒數

·gettimezoneoffset  |  獲取當前時間和utc格式的偏移值(以分鐘為單位)

·getutcdate         |  獲取utc格式的當前日期(本月的幾號)

·getutcday          |  獲取utc格式的今天是星期幾(0-sunday,1-monday...)

·getutcfullyear     |  獲取utc格式的當前年份(四位數字)

·getutchours        |  獲取utc格式的當前小時數(24小時制,0-23)

·getutcmilliseconds |  獲取utc格式的當前毫秒數

·getutcminutes      |  獲取utc格式的當前分鐘數

·getutcmonth        |  獲取utc格式的當前月份(注意從0開始:0-jan,1-feb...)

·getutcseconds      |  獲取utc格式的當前秒數

·getyear            |  根據本地時間獲取當前縮寫年份(當前年份減去1900)

·setdate            |  設定當前日期(本月的幾號)

·setfullyear        |  設定當前年份(四位數字)

·sethours           |  設定當前小時數(24小時制,0-23)

·setmilliseconds    |  設定當前毫秒數

·setminutes         |  設定當前分鐘數

·setmonth           |  設定當前月份(注意從0開始:0-jan,1-feb...)

·setseconds         |  設定當前秒數

·settime            |  設定utc格式的從1970.1.1 0:00以來的毫秒數

·setutcdate         |  設定utc格式的當前日期(本月的幾號)

·setutcfullyear     |  設定utc格式的當前年份(四位數字)

·setutchours        |  設定utc格式的當前小時數(24小時制,0-23)

·setutcmilliseconds |  設定utc格式的當前毫秒數

·setutcminutes      |  設定utc格式的當前分鐘數

·setutcmonth        |  設定utc格式的當前月份(注意從0開始:0-jan,1-feb...)

·setutcseconds      |  設定utc格式的當前秒數

·setyear            |  設定當前縮寫年份(當前年份減去1900)

·tostring           |  將日期時間值轉換成"日期/時間"形式的字串值

·date.utc           |  返回指定的utc格式日期時間的固定時間值

頁面js直接得到系統動態時間完整示例:

顯示動態時間

今天看到乙個動態顯示時間的方法 為了防止以後忘記 貼出來 function show if w 1 if w 2 if w 3 if w 4 if w 5 if w 6 var dn am if hours 12 if hours 0 if minutes 9 if seconds 9 var yc...

頁面顯示動態時間

動態顯示時間 function show if w 1 if w 2 if w 3 if w 4 if w 5 if w 6 var dn am if hours 12 if hours 0 if minutes 9 if seconds 9 var myclock year 年 mouth 月 d...

顯示當前時間(動態)

coding utf 8 time 2020 1 12 16 15 author liuze file time 3.py software pycharm import time 匯入時間模組 import sys def get hms loacal time time.localtime ti...