본문 바로가기
개발공부_Blog/JavaScript

Date객체 1 - 연도, 월, 일, 요일

by 독서개발자 2022. 1. 15.

 

 

요일을 만들어봄 

function today(){
  const date = new Date()
  const year = date.getFullYear()
  const month = date.getMonth()+1
  const day = date.getDate()

  titleDay.textContent = (`${month}월 ${day}일` )
}
today()


function weekend(){
  const date = new Date()
  const week = ['일요일', '월요일', '화요일', '수요일', '목요일', '금요일', '토요일']
  const weekDay = week[date.getDay()] 

  titleWeekend.textContent = (weekDay)
}
weekend()

 

 

 

 

 

 

댓글