jsg jsg - 2 months ago 6
HTML Question

Moment.js creating a popup at a specific time

this is the first time i am using moment.js, but im trying to create a time period for a popup or a button to appear. As this is my first time using this its very unclear through the docs how to go about this:
http://momentjs.com/docs the way i have in mind is through the duration section or manipulate

$('.button').hide();
if(moment.duration(9, 'hours')){
$('.button').show();
}
else{
$('.button').hide();
}


so something like this but i am unsure and I am trying to get it so that the time should start at 9am

jsg jsg
Answer

I've ended up using the get set functions off the site so it will look like this:

$('.button').hide();
if(moment().hours() >= 9 && moment().hours() <= 11){
   $('.button').show();
}
else{
   $('.button').hide();
}

which worked fine for momentjs

Comments