Skip to content
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

why now.diff('2021-01', 'M') === now.diff('2021-02', 'M') === 0? #1369

Closed
davidxiao opened this issue Jan 30, 2021 · 2 comments
Closed

why now.diff('2021-01', 'M') === now.diff('2021-02', 'M') === 0? #1369

davidxiao opened this issue Jan 30, 2021 · 2 comments

Comments

@davidxiao
Copy link

davidxiao commented Jan 30, 2021

today is 2021-01-30,

`
const dayjs = require('dayjs')
const today = dayjs()
const jan = '2021-01'
const feb = '2021-02'

console.log(diff of today - jan = ${today.diff(jan, 'M')})
console.log(diff of today - feb = ${today.diff(feb, 'M')})

diff of today - jan = 0
diff of today - feb = 0
`

what's the logic behind?

How can I get natural month difference instead of based on days?

thanks

@iamkun
Copy link
Owner

iamkun commented Jan 30, 2021

just pass true as the third argument, and you will see why

@davidxiao
Copy link
Author

hmm,
thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants