Skip to content

Instantly share code, notes, and snippets.

@DannyDelott
DannyDelott / getTimeLeft().js
Last active July 6, 2019 13:22
Show time left until noon using Moment.js
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);