码迷,mamicode.com
首页 > 其他好文 > 详细

获取时间并补0

时间:2015-07-16 11:21:14      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:

<script type="text/javascript">
$(function(){
/*indexPage1*/
function Appendzero (obj) {
if (obj < 10) return "0" + obj; else return obj;
}
function getWeek (weeknum) {
if (weeknum == 0) week = "星期日";
if (weeknum == 1) week = "星期一";
if (weeknum == 2) week = "星期二";
if (weeknum == 3) week = "星期三";
if (weeknum == 4) week = "星期四";
if (weeknum == 5) week = "星期五";
if (weeknum == 6) week = "星期六";
return week;
}
function getDateWeek () {
var now = new Date ();
/* var year = now.getFullYear ();//获取四位数年数*/
var month = now.getMonth () + 1;
var date = now.getDate ();
var weeknum = now.getDay ();
var hour = now.getHours ();
var minute = now.getMinutes ();
var second = now.getSeconds ();
var sDate = Appendzero (month) + "月" + Appendzero (date) + "日&nbsp;"+ getWeek (weeknum);
var sTime = Appendzero (hour) + ":" + Appendzero (minute) + ":" + Appendzero (second) + "&nbsp;" ;
$(‘.date‘).html(sDate);
$(‘.time‘).html(sTime);
}
getDateWeek ();
setInterval(function(){
getDateWeek();
},1000);

$(‘.slideOpen‘).click(function(){
$(‘.indexPage1‘).hide();
$(‘.indexPage2‘).show();
});
});
</script>

获取时间并补0

标签:

原文地址:http://www.cnblogs.com/love9happy/p/4650529.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!