var myDate = new Date();
var mytime = myDate.getTime();
事件戳:1446125687262
function getCurrentTime(timestr) {
return new Date(parseInt(timestr) * 1000).toLocaleString().substr(0, 17)
}
转换出来的不对啊?
var myDate = new Date();
var mytime = myDate.getTime();
事件戳:1446125687262
function getCurrentTime(timestr) {
return new Date(parseInt(timestr) * 1000).toLocaleString().substr(0, 17)
}
转换出来的不对啊?
// 格式化时间
function formatTime(timeStamp) {
// 将/[0-9]/位的数字编成/0[0-9]/
function getTwo(s) {
if (parseInt(s) < 10) {
return "0" + s;
} else {
return "" + s;
}
}
if (timeStamp.length < 13) {
timeStamp += "000";
}
var d = new Date(parseInt(timeStamp));
var year = d.getFullYear();
var month = getTwo(d.getMonth() + 1);
var date = getTwo(d.getDate());
var hour = getTwo(d.getHours());
var minute = getTwo(d.getMinutes());
var second = getTwo(d.getSeconds());
return year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second;
}
ahwx1994 (作者)
这个在IOS下不顶用啊
2015-10-30 10:20