The toISOString method return incorrect date.
// Input
var a = new Date("June 08, 2018");
a.toISOString().slice(0, 10);
// Output
"2018-06-07"
// Expected output
"2018-06-08"
Use Z at the end of your date value. This will ignore the ISO timezone conversion and it will give you the value based on your local time.
var a = new Date("June 08, 2018 Z");
var res = a.toISOString().slice(0, 10);
console.log(res);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With