Why startOfMonth results in different timezone that endOfMonth

681 Views Asked by At

I am trying to get proper start and end of month values using date-fns. My browser timezone is UTC+2 (as new Date().getTimezoneOffset() results in -120).

Example code:


console.log('start of month: ', dateFns.startOfMonth(new Date()));
console.log('end of month: ', dateFns.endOfMonth(new Date()));

result:

start of month:  Thu Oct 01 2020 00:00:00 GMT+0200 (czas środkowoeuropejski letni)
end of month:  Sat Oct 31 2020 23:59:59 GMT+0100 (czas środkowoeuropejski standardowy)

Why startOfMonth results in timezone GMT+0200 while endOfMonth results in GMT+1? Is it possible to get proper values of timezones (GMT+0200) for both cases?

0

There are 0 best solutions below