var todayDate=new Date();
function monday(date){
var nowTime = date.getTime() ;
var day = date.getDay() || 7;//周一是每周的第一天
//var day = date.getDay() //周日是每周的第一天
var oneDayTime = 24*60*60*1000 ;
var Monday = nowTime - (day-1)*oneDayTime ;
var mondayTime=new Date(Monday);
var year=mondayTime.getFullYear();
var monMath=mondayTime.getMonth()+1;
var month=(monMath<10) ? "0"+""+monMath+"" : monMath;
var data=(mondayTime.getDate()<10) ? "0"+""+mondayTime.getDate()+"" : mondayTime.getDate();
var mondayDate=""+year+"-"+month+"-"+data+""
return mondayDate;
}
// document.getElementById('222').value = todayDate.format('yyyy-MM-dd');
>
Date.prototype.format = function(format){
var o = {
"M+": this.getMonth() + 1, //month
"d+": this.getDate(), //day
"h+": this.getHours(), //hour
"m+": this.getMinutes(), //minute
"s+": this.getSeconds(), //second
"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
"S": this.getMilliseconds() //millisecond
}
if (/(y+)/.test(format))
format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(format))
format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
return format;
}
var a = document.getElementById("222");
var b = new Date();
a.value=b.format('yyyy-MM-dd');
var d = new Date();
var timenow=d.getFullYear()+'-'+(d.getMonth()+1)+'-'+d.getDate()+' '+d.getHours()+':'+d.getMinutes()+':'+d.getSeconds();
alert(timenow);
document.getElementById('1111').value=timenow;
var day = d.getFullYear()+'-'+(d.getMonth()+1)+'-'+d.getDate();