js 将时间戳格式化为 yyyy-MM-dd HH:mm:ss 格式的字符串

    xiaoxiao2021-03-25  58

    // js 格式化时间戳,显示格式 yyyy-MM-dd HH:mm:ss 。输入的 timestamp 例如 1510452672000 function formatTimestamp( timestamp ) {     var dateObj = new Date( timestamp );          var year = dateObj.getYear() + 1900;     var month = dateObj.getMonth() + 1;     var theDate = dateObj.getDate();     var hour = dateObj.getHours();     var minute = dateObj.getMinutes();     var second = dateObj.getSeconds();     return year +"-"+ month +"-" + theDate + " "+ hour +":"+ minute +":"+ second;      }
    转载请注明原文地址: https://ju.6miu.com/read-40115.html

    最新回复(0)