0👍
I extracted the utc dates then was able to get the date working without it being off by one day.
Something similar to:
<input
type="date"
name="startDate"
:value="startDate && startDate.toISOString().split('T')[0]"
@input="startDate = getDateClean($event.target.valueAsDate)"
autocomplete="off"
class="form-control"
/>
method:{
getDateClean(currDate: Date) {
// need to convert to UTC to get working input filter
console.log(currDate);
let month: number | string = currDate.getUTCMonth() + 1;
if (month < 10) month = "0" + month;
let day: number | string = currDate.getUTCDate();
if (day < 10) day = "0" + day;
const dateStr =
currDate.getUTCFullYear() + "-" + month + "-" + day + "T00:00:00";
console.log(dateStr);
const d = new Date(dateStr);
console.log(d);
return d;
}
}
See running example from answer in https://stackoverflow.com/a/63838211/2875452;
- [Vuejs]-Passing dynamic data to Vue params/routes
- [Vuejs]-Could not resolve view with name 'HelloWorld' in servlet with name 'dispatcherServlet'
Source:stackexchange.com