最近搜索

js 将10位时间戳 转成时间

浏览:528
管理员 2019-09-07 02:51

1565280000(10位)


1.js获取当前时间戳的方法

var timestamp1 = Date.parse(new Date());
var timestamp2 = (new Date()).valueOf();
var timestamp3 = new Date().getTime();

1567824541000

1567824541609

1567824541609

这是13位




如果是10位的话  需要 *1000   

const d = new Date(res.data.data[1].timestamp*1000);

const year = d.getFullYear();

const month = d.getMonth() + 1;

const date = d.getDate();

const hour = d.getHours();

const minute = d.getMinutes();

const second = d.getSeconds();

console.log( year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second)


2019-8-9 0:0:0

联系站长

站长微信:xiaomao0055

站长QQ:14496453