John S.
asked on
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.
Is there a Javascript solution to figure this out?
Thank you for looking.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
moment() represents the current time. I updated the example here: https://jsfiddle.net/pydhj4ev/1/
»bp
»bp
ASKER
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("d ays").inne rHTML = days
document.getElementById("w eeks").inn erHTML = weeks
[/code]
Wow what a nice library that is huh!
[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("d
document.getElementById("w
[/code]
Wow what a nice library that is huh!
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
(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
ASKER