获取系统当前时间。格式化输出
function date2str(d) {
var ret = d.getFullYear() + "-"
ret += ("00" + (d.getMonth() + 1)).slice(-2) + "-"
ret += ("00" + d.getDate()).slice(-2) + " "
ret += ("00" + d.getHours()).slice(-2) + ":"
ret += ("00" + d.getMinutes()).slice(-2) + ":"
ret += ("00" + d.getSeconds()).slice(-2)
return ret;
}
alert(date2str(new Date()));