0

I have date in format "YYYY-MM-DD" 2018-08-26 and i want something like that date.getDay() => return (0-6) and using switch case loop that 0 let dayOfWeek == 'Sun' ...

Is exist some tip get String representation of day ?

Wojciech Abacki
  • 251
  • 1
  • 4
  • 17
  • And another dupe: https://stackoverflow.com/questions/17964170/get-the-weekday-from-a-date-object-or-date-string-using-javascript – Caramiriel Aug 26 '18 at 12:49

1 Answers1

0

You can create an array with the weekdays

let weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']

and then get the weekday for your date like this

let weekday = weekdays[date.getDay()];