Last active
December 16, 2016 06:09
-
-
Save EncodeTheCode/07b15633873fc82258f154867b9d59f2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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(), | |
a='', | |
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;} | |
if(d==1){a='st';} | |
if(d==2){a='nd';} | |
if(d==3){a='rd';} | |
if(d>=4){a='th';} | |
if(d==21){a='st';} | |
if(d==22){a='nd';} | |
if(d==23){a='rd';} | |
if(d>=24){a='th';} | |
if(d==31){a='st';} | |
r=''+w[W]+' '+m[M]+' '+d+a+' '+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