//转化为时间格式 function getDate(timestamp) { timestamp = timestamp.replace("/Date(", "").replace(")/", ""); if (timestamp.indexOf("+") > 0) { timestamp = timestamp.substring(0, timestamp.indexOf("+")); } else if (timestamp.indexOf("-") > 0) { timestamp = timestamp.substring(0, timestamp.indexOf("-")); } let date = new Date(parseInt(timestamp, 10)); let year = date.getFullYear(); let month = date.getMonth() + 1 < 10 ? /*"0" +*/ (date.getMonth() + 1) : date.getMonth() + 1; let currentDate =( date.getDate() < 10 ? /*"0" + */date.getDate() : date.getDate())+" "; let Hours = date.getHours() < 10 ? /*"0" + */date.getHours() : date.getHours(); let Minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(); let Seconds = date.getSeconds() < 10 ? /*"0" +*/ date.getSeconds() : date.getSeconds(); return `${year}年${month}月${currentDate}日${Hours}:${Minutes}:${Seconds}`; }
网上找了好多都不行。。。
原文地址:https://www.cnblogs.com/heheblog/p/10424830.html
时间: 2024-11-05 20:33:45