So I have moment JS, and I need to display the time until next sunday in human readable words:
Next Sunday will be in 5 days, 4 hours, 30 minutes, and 10 seconds.
Moment has a from
method but not an until
method.
There's a function moment.fromNow() which shows things like "in 5 months" or "3 years ago".
http://momentjs.com/docs/#/displaying/fromnow/
why don't you try moment#to
a.to(b) // "in a day"
as for the next sunday,
moment().endOf("week");
might do the trick.
so basically the code you would require will be
var now = moment();
var nextSunday = moment().endOf("week");
now.to(nextSunday)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With