startOf('month') gives last day in previous month
See original GitHub issueDescribe the bug
Start of month is incorrect and showing the last day in previous month.
const from = dayjs.tz(dayjs(),'Europe/London').startOf('month')
const end = dayjs.tz(dayjs(),'Europe/London').endOf('month')
The above when console logged outputs:
from: Thu, 30 Jun 2022 23:00:00 GMT to: Sun, 31 Jul 2022 22:59:59 GMT
Which I think we can all agree is incorrect
Expected behavior
start of time should always return correct times.
Information
- Day.js Version 1.11.3
- OS: Latest chrome on Mac OS
- Browser Chrome
- Time zone: Europe/London
Issue Analytics
- State:
- Created a year ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
MomentJS - How to get last day of previous month from date?
Simply add a endOf('month') to your calls: var dateFrom = moment(dateFrom).subtract(1,'months').endOf('month').format('YYYY-MM-DD');.
Read more >Month method returns previous month · Issue #4299 - GitHub
When I try to use month method on a date in an ISO format, I got a month number from the previous month....
Read more >How to Get the First and Last Day of the Current Month with ...
We can use the startOf method to get the first day of the current month. And we can use the endOf method to...
Read more >Get the First day of the Previous Month in JavaScript
To get the first day of the previous month, use the Date() constructor to create a date object, passing it a call to...
Read more >Get the start and end dates of the previous month the query is ...
date_trunc('month', current_timestamp) gives you the start of "this ... it will include everything on the last day of February (including ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi, this is a correct result, moment.js has the same result. Here is a small demo
I created a simple webpage to test the function:
The result is:
So I cannot reproduce this error neither on Chrome 103 nor in Firefox 103 on my windows 10 machine. Could you try this code on your system?