how can i compare date like moment.duration
See original GitHub issueHow can i get a result like below by dayjs?
const diff = moment.duration(moment("2018-01-01").diff(moment("2019-5-12 10:15:23")));
console.log(diff._date);
// {
years: 1,
months: 5,
days: 12,
hours: 10,
....
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (7 by maintainers)
Top Results From Across the Web
Moment js date time comparison - Stack Overflow
Here, I am comparing two dates i.e. 2014-03-24T01:15:000 > 2014-03-24T01:14:000 , expecting that the first one is greater than the second one, ...
Read more >How to compare two dates with JavaScript? - Tutorialspoint
Moment. js has a diff() method, which gives the difference between two dates in years, months, days, hours, minutes, seconds, milliseconds, etc ...
Read more >Difference - momentjs.com - Read the Docs
See the docs on moment#duration for more info. The supported measurements are years , months , weeks , days , hours , minutes...
Read more >How to Compare the Date Part of a Date Object Only Without ...
The moment.js library has the isAfter method that lets us compare 2 date-times without the time part. To do this, we write:
Read more >Docs - Moment.js
The Date object internally represents a Unix timestamp with millisecond precision. It offers functions that will convert to and from the system's local...
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
@see https://github.com/huangjinlin/dayjs-precise-range
Currently, I’m using RelativeTime to achieve that, but it’s not perfect:
The problem here is that it will show us only years or days or hours etc… It’ll never show something like
2 Hours and 23 Minutes
. It would’ve been super if we could have a plugin that handles that, with an option of how “deep” do we want to be specific (e.g. be specific until minutes), Maybe something like: