码迷,mamicode.com
首页 > 其他好文 > 详细

日期类

时间:2018-12-13 19:16:52      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:min   时间   get   let   pre   EDA   nbsp   minutes   time   

1、将时间戳转换成   2018-12-13 17:35:26

function changeDate(time){
    if(!!time){
        let getTime = parseInt(time) * 1000;
        let date = new Date(getTime);
        let year = date.getFullYear();
        let month = parseInt(date.getMonth()) + 1;
        if(month < 10){
                month = "0" + month;
        }
        let day = date.getDate();
        if(day < 10){
                day = "0" + day;
        }
        let hours = date.getHours();
        if(hours < 10){
                hours = "0" + hours;
        }
        let minutes = date.getMinutes();
        if(minutes < 10){
                minutes = "0" + minutes;
        }
        let seconds = date.getSeconds();
        if(seconds < 10){
                seconds = "0" + seconds;
        }
        return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
        }else{
            return ‘‘;
        }
}

 

日期类

标签:min   时间   get   let   pre   EDA   nbsp   minutes   time   

原文地址:https://www.cnblogs.com/haishen/p/10115463.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!