标签:time gets ring get turn min 补齐 second code
function getnowtime() { var nowtime = new Date(); var year = nowtime.getFullYear(); var month = padleft0(nowtime.getMonth() + 1); var day = padleft0(nowtime.getDate()); var hour = padleft0(nowtime.getHours()); var minute = padleft0(nowtime.getMinutes()); var second = padleft0(nowtime.getSeconds()); var millisecond = nowtime.getMilliseconds(); millisecond = millisecond.toString().length == 1 ? "00" + millisecond : millisecond.toString().length == 2 ? "0" + millisecond : millisecond; return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second + "." + millisecond; } //补齐两位数 function padleft0(obj) { return obj.toString().replace(/^[0-9]{1}$/, "0" + obj); }
标签:time gets ring get turn min 补齐 second code
原文地址:http://www.cnblogs.com/WJ--NET/p/6003314.html