All pastes #1905072 Raw Edit

JavaScript Clock

public javascript v1 · immutable
#1905072 ·published 2010-07-21 05:54 UTC
rendered paste body
<script type="text/javascript">/* JavaScript Clock - Example usage: <body onload="clock('<?php echo date("F d, Y H:i:s",time())?>');"> LTDev - http://ltdev.us/*/function clock (date) {         if (typeof(sdate) == "undefined") {            sdate = new Date(date);         }         sdate.setSeconds(sdate.getSeconds()+1);         var h = sdate.getHours(), m = sdate.getMinutes(), s = sdate.getSeconds(), ap = 'AM';         if (h > 12) { h = h-12; ap = 'PM'; }         var time = (h==0?"12":(h>9?h:"0"+h))+":"+(m>9?m:"0"+m)+":"+(s>9?s:"0"+s);         if ((timeLoc = document.getElementById("time")) != null) {            timeLoc.innerHTML = "<strong>"+time+" "+ap+"</strong>";         }         window.setTimeout(function(){clock();},1000);}</script>