Home > front end >  Js, new Date (). ToLocaleString () how to get the correct Date and time
Js, new Date (). ToLocaleString () how to get the correct Date and time

Time:01-30

Var a=44195.09027777778//time is: 2020/12/31 02:10:00
The date=new date (1900, 0, a). The toLocaleString ();
The console. The log (date); Shows the result is: the 12:00:00 2020/12/31 morning, time error, how to set a new date parameters can obtain the correct date and time??

CodePudding user response:

The parameters of the Date () does not support the decimal

Var a=44195.09027777778//time is: 2020/12/31 02:10:00
Var s=new Date (0, 1900). GetTime () + a * 24 * 60 * 60 * 1000;
The date=new date (s). ToLocaleString ();