Doesn't add day
See original GitHub issueVersion:1.7.5 Wasn’t reproducible on version 1.6.x (don’t remember now) Similar issue to: https://github.com/iamkun/dayjs/issues/262
Trying to add day to 28 of October 2018 doesn’t add anything: https://codepen.io/lexswed/pen/NLaRZY
console.log(dayjs('2018-10-28').format('MMM dd DD'))
console.log(dayjs('2018-10-28').add(1, 'day').format('MMM dd DD'))
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
MS Project 2013 Can't add 'days' correctly
MS Project 2013 Can't add 'days' correctly. When I set duration to '2 days' the calendar advances only 1 day.
Read more >3 Ways to Add or Subtract Days to a Date - Excel Campus
Learn 3 different ways to add or subtract days to dates in Excel using formulas, copy & paste, and VBA macros. Includes video...
Read more >Adding/Subtracting days from a date doesn't change the year ...
I think you meant to do this: (working perfectly) var date = new Date('2011','01','02'); alert('the original date is '+date); var newdate = new...
Read more >How to add and subtract dates in Excel - Ablebits
See how to quickly subtract or add two dates, add days to a date, add or subtract weeks, months and years, and calculate...
Read more >How to Add Days to Dates in Excel - YouTube
In this video we look at 3 different ways to add or subtract days to dates in Excel using formulas, ... Your browser...
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 FreeTop 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
Top GitHub Comments
@nukuuk @LexSwed You may could try v1.7.7 and check if this issue is fixed in your timezone. THX.
@LexSwed, you need to consider the fact, that
dayjs
works in the local time zone by default, just likeDate
. There are PRs #168 and #326 to introduce a “UTC mode” which will allow work with an apparent “date-only” value, which you use in your case.Your case is similar to #262, #249 and #74.
When you constructed the
dayjs
instance like this:you assumed, that it works like a “date-only” instance. After adding 1 day, you expected it to become like
dayjs('2018-10-28')
. However, it was wrong. Bothdayjs
andDate
assumed, that you supplied a string in UTC and you just omitted the time part. You actually performed the following initialization:It means, that you have a full date+time object. Both
dayjs
andDate
work in the local time zone by default, which you can confirm by using getters, setters andtoString
. The actually stored value will be this in Central Europe:Depending on DST changes in your local time zone, adding or subtracting a day may result in an hour shift, which may affect your day value. If you want to prevent it, you need to use setters with
UTC
in their name, when working withDate
. When working withdayjs
you can do nothing, because there are no UTC-setters there yet. You workaround will work, or you can try the UTC mode from the PRs.