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
work out time left #511
Comments
Really need help with this it always seems to end up 1 day out any suggestions? |
You should pass Check this: http://jsfiddle.net/x5LnX/1/ |
ok thanks ;) |
It may be better to use the duration object for this. var diff = moment('2012-11-19T00:00:00+0000').diff(moment()); // in milliseconds
var duration = moment.duration(diff);
console.log(duration.years() + ' years'); // 0 years
console.log(duration.months() + ' months'); // 0 months
console.log(duration.days() + ' days'); // 2 days
console.log(duration.hours() + ' hours'); // 6 hours
console.log(duration.minutes() + ' minutes'); // 43 minutes
console.log(duration.seconds() + ' seconds'); // 41 seconds
console.log(duration.milliseconds() + ' milliseconds'); // 250 milliseconds Formatting durations has been addressed a few times, see #463 and #264 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What i am trying to do is do a countdown to work out the time left from now.
example i have
which will output
but its not working out overall its doing it individuals for each value (days,weeks,months)
so if i up the date by say 12 months like below.
it outputs.
where as i am trying to get it to output
I posted on stack overflow and go some help but their still seems to be issues with weeks here is the solution we came to.
http://jsfiddle.net/fDmWH/6/
The text was updated successfully, but these errors were encountered: