USing moment.js to format date

by chridam

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment.js"></script>
<span id="something">This is a test</span>

JavaScript

var now = moment().format("dddd, MMMM Do, YYYY");
     // Saturday, June 9th, 2007, 5:46:21 PM
console.log(now);
$('#something').hide();

function showSomething(){
   $('#something').show();
};

function refreshAt(hours, minutes, seconds) {
   var now = new Date();
   var then = new Date();

   if(now.getHours() > hours || (now.getHours() == hours && now.getMinutes() > minutes) || now.getHours() == hours && now.getMinutes() == minutes && now.getSeconds() >=  seconds) {
           then.setDate(now.getDate() + 1);
   }
   then.setHours(hours);
   then.setMinutes(minutes);
   then.setSeconds(seconds);

   var timeout = (then.getTime() - now.getTime());
   setTimeout( showSomething, timeout);
};

refreshAt(10, 50, 00);