标签:时间 console var current mon timestamp get function cti
时间戳转
时间戳转
currentTime(1500002100000);
function currentTime(timestamp){
timestamp = new Date(timestamp);
var year = timestamp.getFullYear();
var month = timestamp.getMonth() + 1;
var date = timestamp.getDate();
var hour = timestamp.getHours();
var minute = timestamp.getMinutes();
if(month < 10) {
month = ‘0‘ + month;
}
if(date < 10) {
date = ‘0‘ + date;
}
if(hour < 10) {
hour = ‘0‘ + hour;
}
if(minute < 10) {
minute = ‘0‘ + minute;
}
var currentdate = year + month + date + hour + minute;
alert(currentdate) ;
}
var timer = "2017/06/14 11:15"
var date = new Date(timer);
console.log(date.getTime());
标签:时间 console var current mon timestamp get function cti
原文地址:http://www.cnblogs.com/RAINHAN/p/7010766.html