Get First and Last day of Current Date in jQuery

Last Reply one year ago By pandeyism

Posted one year ago

hi

I want to learn how to get first and last day of current month in datepicker

so the result should be 

2019-04-01

2019-04-30

its not working. first and last day not correct calculate

var bdate = new Date();
var edate = new Date();
bdate.setMonth(bdate.getMonth(), 1);
edate.setMonth(edate.getMonth() + 1, 0);

var firstDayofyear = bdate.toISOString().slice(0, 10);
var lastDayofyear = edate.toISOString().slice(0, 10);

$('#datepickerbeg').val(firstDayofyear);
$('#datepickerend').val(lastDayofyear );

 

This question does not have replies that have been liked.