Created
June 24, 2014 11:02
-
-
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
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
<span class="status">loading</span> |
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
$(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