HTML
<body>
<h1>만 보 걷기</h1>
<p>
<span id="result"></span>
일 연속 달성!</p>
</body>
CSS
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
height: 100vh;
}
h1 {
margin-bottom: 20px;
border-bottom: 1px solid #999;
padding-bottom: 5px;
}
#result {
font-size: 1.5em;
font-weight: bold;
color: tomato;
}
Javascript
const today = new Date();
const firstDay = new Date("2023-02-28");
const result = document.querySelector("#result");
let passedTime = today.getTime() - firstDay.getTime();
let passedDay = Math.round(passedTime / (24 * 60 * 60 * 1000));
result.innerText = passedDay;
'Javascript > GMA(2302~)' 카테고리의 다른 글
23.04.19 자바스크립트 수학객체 (가위바위보게임) (0) | 2023.04.19 |
---|---|
23.04.19 자바스크립트 내장객체(*Date 객체) - 디지털 시계 만들기-2 (0) | 2023.04.19 |
23.04.19 자바스크립트 내장객체(*Date 객체) - 아날로그 시계 만들기 (0) | 2023.04.19 |
23.04.19 자바스크립트 내장객체(*Date 객체) - 디지털 시계 만들기 (0) | 2023.04.19 |
23.04.19 자바스크립트 내장객체(*Date 객체) (0) | 2023.04.19 |