Skip to content

Instantly share code, notes, and snippets.

@telekineticyeti
Created May 29, 2013 13:50
Show Gist options
  • Save telekineticyeti/5670387 to your computer and use it in GitHub Desktop.
Save telekineticyeti/5670387 to your computer and use it in GitHub Desktop.
JQuery clock routine for adding a time/date element to the page that updates every second.
/*
JQuery clock routine for adding a time/date element to the page that updates every second.
*/
jQuery(document).ready(function(){
jQuery.noConflict();
function clockUpdate() {
var myDate = new Date();
var displayDate = (myDate.getDate()) + '/' + (myDate.getMonth()+1) + '/' + myDate.getFullYear();
var displayTime = (myDate.getHours()) + ':' + (myDate.getMinutes()<10?'0':'') + (myDate.getMinutes()) + ':' + (myDate.getSeconds∏()<10?'0':'') + (myDate.getSeconds());
jQuery('.floatingClock .fcTime').text(displayTime);
jQuery('.floatingClock .fcDate').text(displayDate);
}
clockUpdate();
floatingClock = setInterval (function() {
clockUpdate();
}, 1000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment