时间戳为-820889653是怎么计算出来的

网页上用开发工具看到有些时间戳是负数,不知道是怎么计算出来的

第1个回答  2017-09-17
通过下面的方式可以获取宝宝出生的天数

var birthStr = '2013-02-14 10:10:10'.replace(/-/g,'/');
var birthDay = new Date(birthStr).getTime();
var now = new Date().getTime();

var hours = (now - birthDay)/1000/60/60;
var year = Math.floor(hours / (24 * 30 * 12));
hours = hours % (24 * 30 * 12);
var months = Math.floor(hours / (24 * 30 ));
hours = hours % (24 * 30 );
var days = Math.floor(hours / (24));

console.log('已经出生:'+ year+ '年'+ months +'月'+days +"天");本回答被网友采纳
相似回答