jQuery /Date(0000000000000)/日期转换

时间:2020-10-26 19:44:30   收藏:0   阅读:52
    //年月日
    function ChangeDateFormat(cellval) {
        var date = new Date(parseInt(cellval.replace("/Date(", "").replace(")/", ""), 10));
        var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
        var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
        return date.getFullYear() + "-" + month + "-" + currentDate;
    }

    //时分秒
    function ChangeDateFormat1(cellval) {
        var date = new Date(parseInt(cellval.replace("/Date(", "").replace(")/", ""), 10));
        var hours = date.getDate() < 10 ? "0" + date.getHours() : date.getHours();
        var inutes = date.getDate() < 10 ? "0" + date.getMinutes() : date.getMinutes();
        var seconds = date.getDate() < 10 ? "0" + date.getSeconds() : date.getSeconds();
        return hours + ":" + inutes + ":" + seconds;
    }

 

原文:https://www.cnblogs.com/duhaoran/p/13879127.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!