从JavaScript时代开始,我怎么能得到几天?
为了获得新纪元,您需要使用Math.abs()JavaScript方法。然后使用Math.Floor()方法获取自历元以来的日期与当前日期之间的差-
示例
<html>
<head>
<title>JavaScript Clone Date</title>
</head>
<body>
<script>
var current_date, epocDate;
current_date = new Date();
document.write("Current Date: "+current_date);
var epocDate = new Date(new Date().getTime() / 1000);
document.write("<br>Since epoch: "+epocDate);
var res = Math.abs(current_date - epocDate) / 1000;
//获取两个日期之间的总天数
var days = Math.floor(res / 86400);
document.write("<br>Difference (Days): "+days);
</script>
</body>
</html>输出结果
Current Date: Fri May 25 2018 15:42:43 GMT+0530 (India Standard Time) Since epoch: Sun Jan 18 1970 21:44:03 GMT+0530 (India Standard Time) Difference (Days): 17658
热门推荐
1 如何训练狗狗不叫
2 训练狗狗不叫
3 训练狗狗随行
4 怎么训练狗狗不叫
7 训练比熊狗狗教程
10 上海狗狗训练
11 怎么训练狗狗上厕所
12 训练狗狗趴下
13 狗狗服从训练
14 训练狗狗拒食
15 训练狗狗笑
16 训练狗狗大便
17 训练狗狗立
18 训练狗狗捡东西