Replies: 1 comment
-
Seems like problem was the Date constructor, as I am using a date string new Date('2022-02-23'). When I changed this to create date manually new Date(2022,02,23), it fixed all the issues. So guess date string can cause inconsistent results even with the same time zone? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I am using date-fns for the first time in my project. I need to give user the ability to add a month to current date. I'm wondering how is this supposed to work with different length months. I tried different months with 30 and 31 days and I cannot make sense of it.
If I add a month to July 1, 2022 I get July 31, 2022 but if I add a month to July 7 I get Aug, 7, 2022. In first case it seems like it is adding exactly 30 days while in the second case it is adding 31 days. Is that how it is supposed to be?
Also, I added a month to Feb, 15 2023 and the result I got is March, 14 2023. Does this have something to do with timezone offset? I am using Date.parse() to parse a date string and then adding a month to it. My UTC offset is -4.
Appreciate if someone can advise. I have not worked much with dates and this has my head spinning.
Thanks
Beta Was this translation helpful? Give feedback.
All reactions