关于js的时间格式化问题

    xiaoxiao2021-08-26  75

    // 获取当前时间 function getNowFormatDate(obj) { var date = new Date(obj*1000); var seperator1 = "-";//年月日的显示效果 var seperator2 = ":";//时分秒的显示效果 var month = date.getMonth() + 1; var strDate = date.getDate(); if (month >= 1 && month <= 9) { month = "0" + month; } if (strDate >= 0 && strDate <= 9) { strDate = "0" + strDate; } function get(i){return (i < 10 ? '0' : '') + i} var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate + " " + get(date.getHours()) + seperator2 + get(date.getMinutes()) + seperator2 +get(date.getSeconds()); /ar currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate + " " + get(date.getHours()) + seperator2 + get(date.getMinutes()) + seperator2 +get(date.getSeconds()); return currentdate; }

    显示结果为

    2016-11-18 10:00:00

    转载请注明原文地址: https://ju.6miu.com/read-677184.html

    最新回复(0)