Skip to content

Instantly share code, notes, and snippets.

@EncodeTheCode
Last active December 16, 2016 06:01
Show Gist options
  • Save EncodeTheCode/2ed93f8c484a03167b98ac74cf2175d9 to your computer and use it in GitHub Desktop.
Save EncodeTheCode/2ed93f8c484a03167b98ac74cf2175d9 to your computer and use it in GitHub Desktop.
function date_time(id){var D=new Date,year=D.getFullYear(),M=D.getMonth(),m=['January','February','March','April','May','June','July','August','September','October','November','December'],d=D.getDate(),W=D.getDay(),w=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],h=D.getHours(),x=D.getMinutes(),s=D.getSeconds();if(h<10){h="0"+h;}if(x<10){x="0"+x;}if(s<10){s="0"+s;}r=''+w[W]+' '+m[M]+' '+d+' '+year+' '+h+':'+x+':'+s;document.getElementById(id).innerHTML=r;setTimeout('date_time("'+id+'");','1000');return true;}window.onload=date_time('date_time');
/* To use this JavaScript, just add a DOM element and add the id parameter to it with the value date_time (<span id="date_time"></span>). */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment