Skip to content

Instantly share code, notes, and snippets.

@joshi-kumar
Created March 3, 2018 17:06
Show Gist options
  • Save joshi-kumar/fe9a0b82a57684d3be94ab8e4a8b1469 to your computer and use it in GitHub Desktop.
Save joshi-kumar/fe9a0b82a57684d3be94ab8e4a8b1469 to your computer and use it in GitHub Desktop.
JQuery Date time (Watch)
Html File Code
===============================
<!doctype html>
<html>
<head><title> Translate </title>
<script type="text/javascript" src="watch.js">
</script>
</head>
<body>
<div>
<SCRIPT LANGUAGE="JavaScript">
var clocksize=100;
</SCRIPT>
<SCRIPT SRC="http://gheos.net/js/clock.js">
</SCRIPT>
</div>
<div class="time2">
<span id="date_time" style="color:#72a300"> </span>
<script type="text/javascript">
window.onload = date_time('date_time');
</script>
</div>
</body>
</html>
---------------------------
JS file
=================
function date_time(id)
{
date=new Date;
year=date.getFullYear();
month=date.getMonth();
months=new Array('January','February','March','April','May','June','July','August','September','October','November','December');
d=date.getDate();
day=date.getDay();
days=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
h=date.getHours();
if(h<10)
{
h="0"+h;
}
m=date.getMinutes();
if(m<10)
{
m="0"+m;
}
s=date.getSeconds();
if(s<10)
{
s="0"+s;
}
result=''+days[day]+' '+d+', '+months[month]+' '+year+' '+h+':'+m+':'+s;
document.getElementById(id).innerHTML=result;
setTimeout('date_time("'+id+'");','1000');
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment