js处理日期戳
原创截至日期的时间戳
//小于10的补0处理
function checkAddZero(m){
return m < 10 ? 0 + m : m;
}
//根据时间戳转换为日期
function parseDate(shijianchuo)
{
var time = new Date(shijianchuo);
var y = time.getFullYear();
var m = time.getMonth() + 1;//getMonth从0开始(0 ~ 11),所以 + 1
var d = time.getDate();
var h = time.getHours();
var mm = time.getMinutes();
var s = time.getSeconds();
return y + - + checkAddZero(m) + - + checkAddZero(d) +
+ checkAddZero(h) + : + checkAddZero(mm) + : + checkAddZero(s);
}
版权声明
所有资源都来源于爬虫采集,如有侵权请联系我们,我们将立即删除