-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
startOfMonth returning wrong date when input is first day of the month #3761
Comments
I couldn't reproduce this issue in my environment, but I believe it is similar to the problem described in issue #3764. It seems that the date gets processed as a local timezone within date-fns, which could be causing the discrepancy. As mentioned in #3764, using UTCDate should prevent this issue: import { startOfMonth } from "date-fns";
import { UTCDate } from "@date-fns/utc";
console.log(new UTCDate("2021-01-01"));
console.log("START", startOfMonth(new UTCDate("2021-01-01")));
console.log("START", startOfMonth(new UTCDate(2021, 0, 1))); By using UTCDate, you should be able to get consistent results as expected. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I run this:
I get:
The startOfMonth function goes backwards to the previous month.
If I specify the 2nd of the month it works how it should.
The text was updated successfully, but these errors were encountered: