欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JS簡單獲取及顯示當前時間的方法

 更新時間:2016年08月03日 10:24:56   作者:Quber  
這篇文章主要介紹了JS簡單獲取及顯示當前時間的方法,涉及javascript針對日期與時間的獲取與運算相關操作技巧,需要的朋友可以參考下

本文實例講述了JS簡單獲取及顯示當前時間的方法。分享給大家供大家參考,具體如下:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>當前時間</title>
</head>
<body>
 <script>
var now = new Date();
var year = now.getFullYear();    //年
var month = now.getMonth() + 1;   //月
var day = now.getDate();      //日
var hh = now.getHours();      //時
var mm = now.getMinutes();     //分
var clock = year + "-";
if (month < 10)
clock += "0";
clock += month + "-";
if (day < 10)
clock += "0";
clock += day + " ";
if (hh < 10)
clock += "0";
clock += hh + ":";
if (mm < 10) clock += '0';
clock += mm;
document.write(clock);
</script>
</body>
</html>

PS:對JavaScript時間與日期操作感興趣的朋友還可以參考本站在線工具:

Unix時間戳(timestamp)轉換工具:
http://tools.jb51.net/code/unixtime

在線世界各地時間查詢:
http://tools.jb51.net/zhuanhuanqi/worldtime

在線萬年歷日歷:
http://tools.jb51.net/bianmin/wannianli

網(wǎng)頁萬年歷日歷:
http://tools.jb51.net/bianmin/webwannianli

更多關于JavaScript相關內容可查看本站專題:《JavaScript時間與日期操作技巧總結》、《JavaScript切換特效與技巧總結》、《JavaScript查找算法技巧總結》、《JavaScript動畫特效與技巧匯總》、《JavaScript錯誤與調試技巧總結》、《JavaScript數(shù)據(jù)結構與算法技巧總結》、《JavaScript遍歷算法與技巧總結》及《JavaScript數(shù)學運算用法總結

希望本文所述對大家JavaScript程序設計有所幫助。

相關文章

最新評論