當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
JS 取得当前时间日期
生活随笔
收集整理的這篇文章主要介紹了
JS 取得当前时间日期
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
var myDate = new Date();
????myDate.getYear();?????? //獲取當前年份(2位)
????myDate.getFullYear();?? //獲取完整的年份(4位,1970-????)
????myDate.getMonth();??????//獲取當前月份(0-11,0代表1月)
????myDate.getDate();?????? //獲取當前日(1-31)
????myDate.getDay();????????//獲取當前星期X(0-6,0代表星期天)
????myDate.getTime();?????? //獲取當前時間(從1970.1.1開始的毫秒數)
????myDate.getHours();??????//獲取當前小時數(0-23)
????myDate.getMinutes();????//獲取當前分鐘數(0-59)
????myDate.getSeconds();????//獲取當前秒數(0-59)
????myDate.getMilliseconds();?? //獲取當前毫秒數(0-999)
????myDate.toLocaleDateString();????//獲取當前日期
????var mytime=myDate.toLocaleTimeString();????//獲取當前時間
????myDate.toLocaleString( );?????? //獲取日期與時間?
????myDate.getYear();?????? //獲取當前年份(2位)
????myDate.getFullYear();?? //獲取完整的年份(4位,1970-????)
????myDate.getMonth();??????//獲取當前月份(0-11,0代表1月)
????myDate.getDate();?????? //獲取當前日(1-31)
????myDate.getDay();????????//獲取當前星期X(0-6,0代表星期天)
????myDate.getTime();?????? //獲取當前時間(從1970.1.1開始的毫秒數)
????myDate.getHours();??????//獲取當前小時數(0-23)
????myDate.getMinutes();????//獲取當前分鐘數(0-59)
????myDate.getSeconds();????//獲取當前秒數(0-59)
????myDate.getMilliseconds();?? //獲取當前毫秒數(0-999)
????myDate.toLocaleDateString();????//獲取當前日期
????var mytime=myDate.toLocaleTimeString();????//獲取當前時間
????myDate.toLocaleString( );?????? //獲取日期與時間?
轉載于:https://www.cnblogs.com/teacherz/archive/2007/04/12/2353832.html
總結
以上是生活随笔為你收集整理的JS 取得当前时间日期的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: swing组建的层次
- 下一篇: 分布式SOA基础架构崭露头角