首页 > 其他 > 详细

获取当前日期

时间:2016-01-13 12:41:40      阅读:102      评论:0      收藏:0      [点我收藏+]

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>日期</title>
<script type="text/javascript">
function disDate(){
//
var now=new Date();
//
var year = now.getFullYear();
var month = now.getMonth()+1;
var date = now.getDate();
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds();
var ms = now.getMilliseconds();
var day = now.getDay();
var strDay="";
switch(day){
case 1:
strDay="星期一";break;
case 2:
strDay="星期二";break;
case 3:
strDay="星期三";break;
case 4:
strDay="星期四";break;
case 5:
strDay="星期五";break;
case 6:
strDay="星期六";break;
case 0:
strDay="星期日";break;
}
var nowStr=year+"年"+month+"月"+date+"日"
+hour+"时"+minute+"分"+second+"秒"
+ms+"毫秒"+strDay;

//年加分1
now.setFullYear(year+1);
var nextStr= now.toLocaleString();
alert("当前时间是:"+nowStr+"\n\n一年后今天:"+nextStr);
}


</script>
</head>

<body>
<button value="按钮" onClick="disDate()">按钮</button>
</body>
</html>

获取当前日期

原文:http://www.cnblogs.com/sunsie/p/5126650.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!