I have a field with a date value that is always formatted as YYYY-MM-DD.
How can I get the weekday value of this field value.
Example: If the date in the field is a Monday the result should be 1, if it's Tuesday it should be 2 and so on.
I tried the following but this returns NaN for me:
var n = new Date( $('#myFieldID').val() );
var w = n.getDay();
var dateNow = moment().format('YYYY-MM-DD');
I found out that Moment.js also has a weekday function built-in which resolved the issue. Thanks.