Search code examples
javascriptdayofweekisodate

Check day of an ISO date


I have a date field in ISO format like this: 2017-06-06T00:00:00 I'm looking for a way to find if the date string above represents Saturday or Sunday. I've read some post and all of them have a Date object format date and not an ISO date. I really appreciate your help


Solution

  • The Date constructor accepts (a simplified version of) ISO date strings:

    const date = new Date('2017-06-06T00:00:00');
    const day = date.getDay();
    
    console.log(day); // 2 = Tuesday