Skip to content

Instantly share code, notes, and snippets.

@arturmamedov
Created May 4, 2016 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arturmamedov/d36534b4ce2302dcca09bba65ac31239 to your computer and use it in GitHub Desktop.
Save arturmamedov/d36534b4ce2302dcca09bba65ac31239 to your computer and use it in GitHub Desktop.
Update Messages on page at predefined time
function updateMessage (){
// Message and time here. Use GMT Time (est +4)
var messages = [
['09/30/2014 21:10 GMT','Backstage: Next up Text here - @ 10 AM'],
['09/30/2014 21:12 GMT','Its 5:15'],
['09/30/2014 21:20 GMT','Its 5:20'],
['09/30/2014 21:25 GMT','Its 5:25'],
['09/30/2014 21:30 GMT','Its 5:30'],
['09/30/2014 21:35 GMT','Its 5:35'],
['09/30/2014 21:40 GMT','Its 5:40']
];
var d = new Date();
var n = d.toUTCString();
var currentTime = Date.parse(n)/1000;
var currentMessage = '';
$(messages).each(function(index, element) {
var msg = Date.parse(messages[index][0])/1000;
if(currentTime - msg < 0 && currentMessage == ''){
currentMessage = messages[index][1];
}
});
$("#cat_backstage_nextup_text").html(currentMessage);
}
// Set update time here:
$(document).ready(function()
{
updateMessage();
setInterval('updateMessage()', 60000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment