js convert timestamp to "days, hours, minutes and seconds"

You can use the Date object in JavaScript to convert a timestamp into "days, hours, minutes, and seconds." You can use the Date constructor to pass in the timestamp, and then use the getUTCDate, getUTCHours, getUTCMinutes, and getUTCSeconds methods to obtain the days, hours, minutes, and seconds respectively. The code example is as follows:

var timestamp = 1623471235;
var date = new Date(timestamp * 1000);
var days = date.getUTCDate() - 1;
var hours = date.getUTCHours();
var minutes = d

Guess you like

Origin blog.csdn.net/weixin_42576410/article/details/129569696#comments_27354534