设为首页 加入收藏

TOP

用js计算自己从出生到现在生活了多长时间(x天零x小时零x分钟零x秒) 初学者,大家多多包涵,有不足的地方请多包涵。
2019-09-17 17:06:39 】 浏览:24
Tags:计算 自己 出生 现在 生活 多长 时间 天零 小时 分钟 x秒 学者 大家 多多 包涵 不足 地方
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
  <script>
    var now = new Date;
    var bir = new Date(1995,09,24,08,50,10);  //在这里按照这个格式输入自己生日:年月日时分秒
    console.log(bir.getTime() + '<br>');
    console.log(now.getTime() + '<br>');
    var cha = now - bir;
    console.log(cha + '<br>')
    var date = cha / 86400000;
    document.write('出生到现在你已经生活了' + parseInt(date) + '天零');
    var hours1 = (cha % 86400000) / 3600000;
    document.write(parseInt(hours1) + '小时零');
    var minutes1 = (cha % 86400000 % 3600000) / 60000;
    document.write(parseInt(minutes1) + '分钟零');
    var second1 = (cha % 86400000 % 3600000 % 60000)/ 1000;
    document.write(parseInt(second1) + '秒');
  </script>
<title>Document</title>
</head>
<body>
</body>
</html>
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇浅谈async函数await用法 下一篇JavaScript Event Loop和微任务、..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目