How to use Date Utils - getDayOfWeek

  • Hello

    I’m trying to use the getDayOfWeek function. The following code returns a 5 for the first day of 2019. According to the calendar the first day of 2019 is a Tuesday. How do you equate 5 to Tuesday? I would expect it to return either a 3 or a 2 depending on whether a week starts with Sunday or Monday respectively.

    import { date } from "quasar";
    console.log("index is: " + date.getDayOfWeek(new Date(2019, 1, 1)));


  • I’m still fairly new to Javascript and after more research I’ve learned the the month is zero based in Javascript so my above date is actually referring to the Month of February which would make the return result of 5 make sense.

Log in to reply