This article mainly introduces the sample code of converting time from millisecond to datetime in js. For more information, see, I hope this will help you to convert the js Millisecond Time To the date time.
Var oldTime = (new Date ("20:10:10"). getTime (); // get the number of milliseconds
In most cases, we divide the number of milliseconds by 365*24*60*60*60 & 1000. This conversion method is too complicated. We need to obtain different methods, such as year, month, day, and hour, minute, and second, in addition, some years have 366 days and some 365 days, which is too complicated.
I tried a method later and succeeded.
Var oldTime = (new Date ("20:10:10"). getTime (); // get the number of milliseconds var newTime = new Date (oldTime); // get the normal time
You can directly input the number of milliseconds as the parameter to get the normal time for the Date object. Then, you can use getHours, getFullYear, and other methods to get the year, month, day, and hour, minute, and second.
Related Articles:
PHP converts seconds to days, hours, and minutes
PHP converts seconds to days, hours, and minutes.