-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
how can i compare date like moment.duration #414
Comments
Check #122 |
@naulacambra |
Update: Duration have you tried RelativeTime plugin? |
yes, It' can't. |
Can you show the code with RelativeTime plugin that you've tried? |
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
|
@Newbie012 How does momentjs do this? |
@iamkun I haven't used momentjs much in my projects since it's a one-hell-of-a-package :D, so I'm not sure exactly. I don't think MomentJS does it that way. |
@Newbie012 Yes, I don't know much about |
Currently, I haven't found a lightweight maintained package that offers this kind of feature, so I guess it's up to you whether to implement this kind of plugin / API :) |
It's a nice to have feature, why not. 😁 Discussion welcome. |
#564 todo: Duration plugin |
@see https://github.com/huangjinlin/dayjs-precise-range dayjs.extend(preciseDiff);
const duration = dayjs.preciseDiff(dayjs(timeA), dayjs(timeB), true);
const years = duration.years;
const year = years ? `${years}年` : '';
const months = duration.months;
const month = months ? `${months}月` : '';
const days = duration.days;
const day = days ? `${days}天` : '';
const hours = duration.hours;
const hour = hours ? `${hours}小时` : '';
const minutes = duration.minutes;
const minute = minutes ? `${minutes}分` : ''; |
As it said |
How can i get a result like below by dayjs?
The text was updated successfully, but these errors were encountered: