且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将毫秒转换为日期和时间?

更新时间:2023-01-16 09:28:04

Date的构造方法使用数字,而不是字符串.要么直接输入:

Date's constructor takes a number, not a string. Either feed it in directly:

date = 1475235770601; // Note the lack of quotes making it a number

或者,如果您已经有一个字符串,则将其显式转换:

Or, if you already have a string, convert it explicitly:

date = parseInt(date);