I have a little problem with MomentJS returning a meaningless date. I am trying to set the date on the first of this month and year. I tried the following: -
var _year = 2015; var _month = 10; var _dateString = _year.toString() + '-' + _month.toString() + '-1'; var _date = moment(_dateString, 'YYYY-MM-D'); console.log('_date', _date.format('dddd, do MMMM YYYY'));
This gives Thursday, 4th October 2015 as _date . Which does not exist. I tried using .set() and .date() , both give the same result: -
var _date = moment(_dateString, 'YYYY-MM-D').set('date', 1); > Thursday, 4th October 2015 var _date = moment(_dateString, 'YYYY-MM-D').date(1); > Thursday, 4th October 2015
So, I donβt see what Iβm doing right now, can anyone suggest any suggestions or help?
Thank you very much.
source share