如何将毫秒转换为日期(月中的某天)?

How to convert milliseconds to the date ( day of the month )?

我需要从 UNIX 纪元时间获取日期(一个月中的某天)。 我可以从这里得到日期:

new Date ().getDate()

但是我需要从Date.now()获取,Date.now().getDate()给我一个错误..

如何获取该日期(一个月中的第几天)??

您可以将毫秒数传递给 Date 构造函数,例如:

let now = Date.now();
let date = new Date(now).getDate();
console.log(date);