Count Number of Weeks until a date

I need a way to display the number of weeks and days until a certain date ( in my case, August 30th ) to display in a DIV on out site:



Is there a Javascript solution to figure this out?

Thank you for looking.
John S.Web DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill PrewIT / Software Engineering ConsultantCommented:
How about using Moment.js, then this becomes quite easy, as in: https://jsfiddle.net/pydhj4ev/


»bp
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
John S.Web DeveloperAuthor Commented:
Bill can you help me set the start date to right now? Then this will be perfect!
0
Bill PrewIT / Software Engineering ConsultantCommented:
moment() represents the current time.  I updated the example here:  https://jsfiddle.net/pydhj4ev/1/


»bp
1
John S.Web DeveloperAuthor Commented:
this did it, thanks, Bill

[code]
var a = moment();
var b = moment('30/09/2018', 'DD/MM/YYYY');
var days = b.diff(a, 'days');
var weeks = b.diff(a, 'weeks');
document.getElementById("days").innerHTML = days
document.getElementById("weeks").innerHTML = weeks
[/code]

Wow what a nice library that is huh!
0
Bill PrewIT / Software Engineering ConsultantCommented:
Yes, it can be very helpful, and there is a lot to it.

(if you posted your last comment from a mobile device that is what the [code] formatting didn't work, it's a known problem currently...)


»bp
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.