1.0.0 • Published 3 years ago
nm-npm v1.0.0
class Moment{
constructor(time){
this.time=time
}
change(){
let date=new Date(this.time);
let nowtime=new Date();
let newtime=nowtime-date;
let year=Math.floor(newtime/1000/60/60/24/365),
month=Math.floor(newtime/1000/60/60/24/30%12),
day=Math.floor(newtime/1000/60/60/24%30);
console.log(day)
return year+'年'+month+'月'+day+'天'
}
}
console.log(new Moment("2020-3-19").change())
1.0.0
3 years ago