最近需要将一篇文章或评论的发布时间转换为,刚刚,10分钟前……,这种表示方式如下:JavaScript格式化时间/***格式化运行时间*@param{*}值时间戳(毫秒)或时间对象*@returns*/functionelapsed(value){consttime=Date.now()-newDate(value)consttimes=[31536000000,2592000000,86400000,3600000,60000,1000]constunits=['yearsago','monthsago','daysago','hoursago','minutesago','secondsago']让索引=时间.findIndex(t=>t
