十万火急!!javascript 取当前系统时间 只要年月日!
javascript 取当前系统时间 只要年月日!
以 年年年年。月月。日日 的形式!
例 2007.03.29
------解决方案--------------------Date.prototype.Format = function(informat) //author: meizz
{
var inputStr = " ";
var format = this.format;
if(informat!=null)format = informat;
var o = {
"M+ " : this.getMonth()+1,
"d+ " : this.getDate(),
"h+ " : this.getHours(),
"H+ " : this.getHours(),
"m+ " : this.getMinutes(),
"s+ " : this.getSeconds()
}
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 aa = new Date();
alert(aa.Format( "yyyy.MM.dd "));
------解决方案--------------------var aa = new Date();
var y = aa.getYear();
var m = aa.getMonth()+1;
var d = aa.getDate();
if(m <=9) m= "0 "+m;
if(d <=9) d= "0 "+d;
alert(y+ ". "+m+ ". "+d);
经较简单的就这样了