Last active
July 6, 2019 13:22
-
-
Save DannyDelott/2b1583b70f9ad79ebbc5 to your computer and use it in GitHub Desktop.
Show time left until noon using Moment.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var getTimeLeft = function(){ | |
var now = moment(); | |
var deadline = now.clone().hour(12).minute(0),second(0); | |
if(now.isAfter(deadline) { | |
// disable RSVP button here | |
return ‘Closed’; | |
}else { | |
// enable RSVP button here | |
// returns “in x hours”, “in x minutes”, “in a few seconds” | |
return deadline.from(now); | |
} | |
} |
Also, missing a bracket on line 4, should be: if(now.isAfter(deadline)) {
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
comma in
... ,second(0)
instead of a period. Very cool otherwise