#注意得到的数据是否已经*1000
//获取月份
function getMonth(time) { let timeStamp = new Date(time*1000);
let month = timeStamp.getFullYear()+‘ 年‘+(timeStamp.getMonth()+1)+‘月‘
return month;}
//获取月份=》2019年6月 function getMonth(time) { let timeStamp = new Date(time*1000); let month = timeStamp.getFullYear()+‘ 年‘+(timeStamp.getMonth()+1)+‘月‘ return month;}
//获取具体时间=》2019.6.06.12.00 function gettime(time) { let timeStamp = new Date(time*1000); let Deatiltime = timeStamp.getFullYear()+‘.‘+(timeStamp.getMonth()+1).toString().padStart(2,‘0‘)+ ‘.‘ + timeStamp.getHours().toString().padStart(2,‘0‘)+ ‘.‘+ timeStamp.getMinutes().toString().padStart(2,‘0‘) // .replace() return Deatiltime; }
原文:https://www.cnblogs.com/lemonib/p/11282555.html