Created
June 9, 2012 11:49
-
-
Save mattpass/2900665 to your computer and use it in GitHub Desktop.
Live server datetime golfing...
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
| <span id="serverDT"></span> | |
| <script> | |
| var nDT = <?php echo time()*1000; ?>; | |
| setInterval(function(){ | |
| var s=(new Date(nDT+=1e3)+'').split(' '), | |
| d=s[2]*1, | |
| t=s[4].split(':'), | |
| p=t[0]>11?'pm':'am', | |
| e=d%20==1|d>30?'st':d%20==2?'nd':d%20==3?'rd':'th'; | |
| t[0]=--t[0]%12+1; | |
| document.getElementById('serverDT').innerHTML=[s[0],d+e,s[1],s[3],t.join(':')+p].join(' '); | |
| },1000); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@p01 Good point. I chose that format because it looks a little nicer than the regular Date output. In the bigger scheme of things I don't mind the extra 100 bytes or so on my IDE to have this format.