Skip to content

Instantly share code, notes, and snippets.

@PeterTheOne
Created June 24, 2014 11:02
Show Gist options
  • Save PeterTheOne/3b271335bfcd4abb2a36 to your computer and use it in GitHub Desktop.
Save PeterTheOne/3b271335bfcd4abb2a36 to your computer and use it in GitHub Desktop.
Check if time between interval in some timezone. Dependent upon Moment.js and Moment Timezone
<span class="status">loading</span>
$(function() {
var updateStatus = function() {
var now = moment().tz('Europe/Vienna')
var hour = now.format('HH');
if (hour > 10 && hour < 22) {
$('.status').html('<i>It\'s ' + now.format('HH:mm') + ' in Austria and between 10h and 22h.</i>');
} else {
$('.status').html('<i>It\'s ' + now.format('HH:mm') + ' in Austria and not between 10h and 22h.</i>');
};
}
updateStatus();
setInterval(updateStatus, 1000 * 60 * 1);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment