<html>
<head>
</head>
<body>
<div>現在是今年的<span id="daytotal"></span>天————————第<span id="weektotal"></span>周</div>
</body>
<script>
//1.獲取本年已經走過的時間 天數
var d1 = Math.ceil((new Date() - new Date(new Date().getFullYear().toString())) / (24 * 60 * 60 * 1000));
//天數
console.log(d1, "天數");
//2. 代入獲取本年的1月1號是星期幾
var week = new Date(new Date().getFullYear().toString() + "/01/01").getDay();
console.log(week, "代入獲取本年的1月1號是星期幾");
//計算 當前時間是本年的第幾周
var total = Math.ceil((d1 + week - 1) / 7);
//
console.log(total, "計算 當前時間是本年的第幾周")
document.getElementById('weektotal').innerHTML = total;
document.getElementById('daytotal').innerHTML = d1;
</script>
</html>