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();
I am using Moment.js to create the date that goes into that field:
var dateNow = moment().format('YYYY-MM-DD');
$('#myFieldID').val(dateNow);
This works and would fill in 2014-02-13 for the 13th of February 2014.
Many thanks for any help with this, Tim