标签:
var d = new Date();
//补0
var zeroize = function(value){
var length = 2;
value = new String(value);
for (var i = 0, zeros = ‘‘; i < (length - value.length); i++) {
zeros += ‘0‘;
}
return zeros + value;
};
return zeroize(d.getHours()) + ‘:‘ + zeroize(d.getMinutes()) + ‘:‘ + zeroize(d.getSeconds());
/*+ ‘.‘ + zeroize(d.getMilliseconds())*/
},
格式2:2015/11/12 上午 10:11:12
formatTime: function(date_time){
var timestr = new Date(parseInt(date_time) * 1000),
datetime = timestr.toLocaleString().replace(/年|月/g, "-").replace(/日/g, "");
datetime = timestr.toLocaleString().replace(/PM|AM/g, "").replace(/PM|AM/g, "");
return datetime;
},
标签:
原文地址:http://www.cnblogs.com/zengcanxin/p/5269580.html