javascript中拼凑一个10位的系统日期


var myDate = new Date();
var nowyear = myDate.getFullYear(); //获取完整的年份(4位,1970-????)
var nowmonth = myDate.getMonth()+1; //获取当前月份(0-11,0代表1月)
if(nowmonth<10){
nowmonth = "0"+nowmonth;
}
var nowdate = myDate.getDate(); //获取当前日(1-31)
if(nowdate<10){
nowdate = "0"+nowdate;
}
var nowtime = nowyear+"-"+nowmonth+"-"+nowdate;

你可能感兴趣的:(JavaScript)