I need to get the first and last day of the current month, this works perfectly but when I format the date to looks like this yyyy/mm/dd it changes from the one I passed
For example, if a passed the 1 May 2020 when I format the date returns me the 30 April 2020
var startID = document.getElementById('start');
var datenow = new Date();
var firstday = new Date(datenow.getFullYear(), datenow.getMonth(), 1);
firstday = firstday.toISOString().slice(0, 10);
startID.value = firstday;
<input type="date" name="start" class="form-control" id="start" required autofocus>
<label for="start">Start Date</label>
This is how I get the first day of the current month:
var datenow = new Date();
var firstday = new Date(datenow.getFullYear(),datenow.getMonth(), 1);
This is how I format the date to looks like yyyy/mm/dd in this part is where I get another wrong date from the passed one:
firstday = firstday.toISOString().slice(0,10);