
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
// 목표 날짜 설정 (예시: 2023년 1월 1일)
const targetDate = new Date("2023-12-25T00:00:00Z");
function updateCountdown() {
// 현재 한국 시간을 얻어오기
const now = new Date(new Date().toLocaleString("en-US", { timeZone: "Asia/Seoul" }));
// 남은 시간 계산
const timeRemaining = targetDate - now;
// 시간, 분, 초 계산
const days = Math.floor(timeRemaining / (1000 * 60 * 60 * 24));
const hours = Math.floor((timeRemaining % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((timeRemaining % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((timeRemaining % (1000 * 60)) / 1000);
// 결과를 HTML에 업데이트
const countdownElement = document.getElementById('countdown');
countdownElement.style.color = '#FF9EA9'
countdownElement.innerHTML = `
<span>D-${days} ${hours}시간${minutes}분${seconds}초</span>`;
}
// 페이지 로드 시에도 업데이트 수행
updateCountdown();
// 1초마다 업데이트
setInterval(updateCountdown, 1000);보고 계신 화면 전체를 캡처해 주시면, 튜터님들이 빠르게 상황을 이해할 수 있어요.
