Convert js millisecond time to date time
var oldTime = (new Date("2011/11/11 20:10:10")).getTime(); //得到毫秒数
Most of them use milliseconds divided by 365*24*60*60&1000 to convert it back. This method is too complicated to convert, year, month and day. , hours, minutes and seconds have to be obtained in different ways, and some years have 366 days, and some have 365 days, so it is too complicated to calculate.
I tried a method later and it actually worked
var oldTime = (new Date("2011/11/11 20:10:10")).getTime(); //得到毫秒数 var newTime = new Date(oldTime); //就得到普通的时间了
Directly pass in the milliseconds as a parameter and give it to the Date object to get the ordinary time, and then use getHours, getFullYear, etc. Method to get the year, month, day, hours, minutes and seconds
Related articles: