标签:htm log www sub gets .com html date() get
原文:JS时间戳转时间格式//转化为时间格式 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}`; }
网上找了好多都不行。。。
标签:htm log www sub gets .com html date() get
原文地址:https://www.cnblogs.com/lonelyxmas/p/10474505.html