How can I calculate the first day of the month in ISO standard?
I've used the following solution but when I try to convert it to ISO standard I get the last day of month.
// ONLINE-RUNNER:browser; let date = new Date('Mon Aug 02 2021'); let firstDay = new Date(date.getFullYear(), date.getMonth(), 1); console.log(firstDay); // Sun Aug 01 2021 console.log(firstDay.toISOString()); // 2021-07-31T22:00:00.000Z
I want to receive the following output:
toISOString() method returns always time as ISO 8601, where the timezone is always set to zero offset according to global time what is denoted by the
Your local time has 2 hours different than global time.
date variable contains
2021-08-01 00:00 in your local time (GMT+0200)
firstDay variable contains
2021-07-31 22:00 in global time (offset zero)