方法functionformattimedetail timestamp ) if ! isnantimestamp ) ) consttimestamptotime=timestamp ) ) const date=new date timestamp ); //时间戳要达到10位*1000,时间戳为13位时,1000 const Y=date.getFullYear ); Constm=date.getmonth ) )1 10? ‘0’date.getmonth1) : date.getMonth ) ) 1; const D=date.getDate ; const h=date.getHours ) ) 10? ‘0’ date.getHours ) : date.getHours ); const m=date.getMinutes ) 10? ‘0’ date.getMinutes ) : date.getMinutes ); const s=date.getSeconds ) 10? ‘0’ date.getSeconds ) : date.getSeconds ); 返回y ‘年’ m ‘月’ d ‘日’ ‘ h ‘:’ m ‘:’ s; ; 常数新=新日期timestamp; //日期const nowDayOfWeek=now.getDay ; //每周的第几天constnowdayofhours=now.get hours ; //第几个小时const weekFormat={ 1: ‘星期一’,2: ‘星期二’, ‘星期三’,4: ‘星期四’,5: ‘星期六’,0: 常数week=week format [ now day ofweek ]; let timeProgress=’ ‘; if nowdayofhours=1nowdayofhours=5) { timeProgress=’北京时间凌晨’; } else if 新天堂5新天堂=6) { timeProgress=’北京时间清晨’; } else if nowdayofhours6nowdayofhours=11 ) { timeProgress=’北京时间早晨’; } else if nowdayofhours 11 nowdayofhours=13 ) { timeProgress=’北京时间中午’; } else if nowdayofhours 13 nowdayofhours=17 ) {时间进度=’北京时间下午’; } else if nowdayofhours 17 nowdayofhours=18 ) {时间进度=’北京时间傍晚’; } else if nowdayofhours 18 nowdayofhours=24 ) { timeProgress=’北京时间晚’; } else { timeProgress=’北京时间午夜’; } const cdata={ ‘date’: date,’ week’: week,’ time progress ‘ : time progress }; 返回数据; } else { return ‘ ‘; }; 调用和打印eg: