jquery获取当前日期的方法
本文实例讲述了jquery获取当前日期的方法。分享给大家供大家参考。
具体如下:
<html>
<head>
<metahttp-equiv="content-type"content="text/html;charset=utf-8"/>
<title>jquery当前日期</title>
<scripttype="text/javascript"src="jquery-1.8.2.min.js"></script>
<scripttype="text/javascript">
$(function(){
functionshow(){
varmydate=newDate();
varstr=""+mydate.getFullYear()+"年";
str+=(mydate.getMonth()+1)+"月";
str+=mydate.getDate()+"日";
returnstr;
}
$("input[type='button']").click(function(){
$("p").html("今天是"+show());
});
});
</script>
</head>
<body>
<inputtype="button"value="看看现在的时间"/>
<p></p>
</body>
</html>
PS:这里再为大家推荐几款时间及日期相关在线工具供大家参考使用:
在线日期/天数计算器:
http://tools.jb51.net/jisuanqi/date_jisuanqi
在线日期计算器/相差天数计算器:
http://tools.jb51.net/jisuanqi/datecalc
在线日期天数差计算器:
http://tools.jb51.net/jisuanqi/onlinedatejsq
Unix时间戳(timestamp)转换工具:
http://tools.jb51.net/code/unixtime
希望本文所述对大家的jQuery程序设计有所帮助。