Search Results

Search found 1 results on 1 pages for 'momentjs'.

Page 1/1 | 1 

  • moment.js work out time left

    - by user1503606
    I am trying to get my head around the moment.js library as it seems more stable than the jquery one and the jquery date one is output console errors. http://momentjs.com/docs/#/manipulating/ What i am trying to do is do a countdown to work out the time left from now. example i have var countDownTill = '2012-11-19 00:00:00 +0000'; document.write(moment(countDownTill).diff(moment(), 'months') + " months<br>"); document.write(moment(countDownTill).diff(moment(), 'weeks') + " weeks<br>"); document.write(moment(countDownTill).diff(moment(), 'days') + " days<br>"); which will output 0 months 1 weeks 4 days 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. var countDownTill = '2013-11-19 00:00:00 +0000'; document.write(moment(countDownTill).diff(moment(), 'months') + " months<br>"); document.write(moment(countDownTill).diff(moment(), 'weeks') + " weeks<br>"); document.write(moment(countDownTill).diff(moment(), 'days') + " days<br>"); it outputs. 12 months 53 weeks 369 days where as i am trying to get it to output 12 months 2 weeks 5 days example here http://jsfiddle.net/fDmWH/3/

    Read the article

1