How to get the day of the week from the day number in JavaScript?

后端 未结 8 1118
野的像风
野的像风 2020-12-03 07:05

Given dayNumber is from 0 - 6 representing Monday - Sunday respectively.

Can the Date /

8条回答
  •  抹茶落季
    2020-12-03 07:21

    let today= new Date()
    
    //Function To Convert Day Integer to String
    
    function daysToSrting() {
      const daysOfWeek = ['Sunday', 'Monday','Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
      return daysOfWeek[today.getDay()]
    }
    
    console.log(daysToSrting())
    

提交回复
热议问题