获取每天的年月日
html部分:
<div id="hq-time"></div>
js部分:
function show() {
var mydate = new Date();
var year = mydate.getFullYear();
var month = mydate.getMonth() + 1;
var data = mydate.getDate();
if(month<10){
month= "0"+month; //如果小于10则补0
}
if(data<10){
data= "0"+data;
}
var str = "" + year + "-";
str += month + "-";
str +=data ;
return str;
}
$("#hq-time").html(show());