Digital Clock

Written by @kerixa 23 February 2014

Have a nice digital clock in your page. This code will show time dynamically in your page. Note that you must download the images and insert it in the proper path.

Code Snippet:

                                                
                                                <!-- this script is provided by https://www.htmlbestcodes.com coded by: Kerixa Inc. -->

<table cellpadding="5"><td bgcolor="black">
<img src="http://htmlbestcodes.com/files/dg_clock/dg8.gif" name="hr1"><img 
src="http://htmlbestcodes.com/files/dg_clock/dg8.gif" name="hr2"><img 
src="http://htmlbestcodes.com/files/dg_clock/dgc.gif"><img 
src="http://htmlbestcodes.com/files/dg_clock/dg8.gif" name="mn1"><img 
src="http://htmlbestcodes.com/files/dg_clock/dg8.gif" name="mn2"><img 
src="http://htmlbestcodes.com/files/dg_clock/dgc.gif"><img 
src="http://htmlbestcodes.com/files/dg_clock/dg8.gif" name="se1"><img 
src="http://htmlbestcodes.com/files/dg_clock/dg8.gif" name="se2"><img 
src="http://htmlbestcodes.com/files/dg_clock/dgpm.gif" name="ampm"></td></table>

<script type="text/javascript">
// (c) 2000-2009 ricocheting.com

dg0=new Image();dg0.src="http://htmlbestcodes.com/files/dg_clock/dg0.gif";
dg1=new Image();dg1.src="http://htmlbestcodes.com/files/dg_clock/dg1.gif";
dg2=new Image();dg2.src="http://htmlbestcodes.com/files/dg_clock/dg2.gif";
dg3=new Image();dg3.src="http://htmlbestcodes.com/files/dg_clock/dg3.gif";
dg4=new Image();dg4.src="http://htmlbestcodes.com/files/dg_clock/dg4.gif";
dg5=new Image();dg5.src="http://htmlbestcodes.com/files/dg_clock/dg5.gif";
dg6=new Image();dg6.src="http://htmlbestcodes.com/files/dg_clock/dg6.gif";
dg7=new Image();dg7.src="http://htmlbestcodes.com/files/dg_clock/dg7.gif";
dg8=new Image();dg8.src="http://htmlbestcodes.com/files/dg_clock/dg8.gif";
dg9=new Image();dg9.src="http://htmlbestcodes.com/files/dg_clock/dg9.gif";
dgam=new Image();dgam.src="http://htmlbestcodes.com/files/dg_clock/dgam.gif";
dgpm=new Image();dgpm.src="http://htmlbestcodes.com/files/dg_clock/dgpm.gif";

function dotime(){ 
theTime=setTimeout('dotime()',1000);
d = new Date();
hr= d.getHours()+100;
mn= d.getMinutes()+100;
se= d.getSeconds()+100;
if(hr==100){hr=112;am_pm='am';}
else if(hr<112){am_pm='am';}
else if(hr==112){am_pm='pm';}
else if(hr>112){am_pm='pm';hr=(hr-12);}
tot=''+hr+mn+se;
document.hr1.src = 'http://htmlbestcodes.com/files/dg_clock/dg'+tot.substring(1,2)+'.gif';
document.hr2.src = 'http://htmlbestcodes.com/files/dg_clock/dg'+tot.substring(2,3)+'.gif';
document.mn1.src = 'http://htmlbestcodes.com/files/dg_clock/dg'+tot.substring(4,5)+'.gif';
document.mn2.src = 'http://htmlbestcodes.com/files/dg_clock/dg'+tot.substring(5,6)+'.gif';
document.se1.src = 'http://htmlbestcodes.com/files/dg_clock/dg'+tot.substring(7,8)+'.gif';
document.se2.src = 'http://htmlbestcodes.com/files/dg_clock/dg'+tot.substring(8,9)+'.gif';
document.ampm.src= 'http://htmlbestcodes.com/files/dg_clock/dg'+am_pm+'.gif';
}
dotime();

</script>
<a target='_blank' href='https://www.htmlbestcodes.com' style='font-size: 8pt; text-decoration: none'>Html Best Codes</a>                                                
                                            

Example:


About @kerixa

I am Krishna Eydat. I studied Software Engineering at University of Waterloo in Canada. I lead a few tech companies. I am passionate about the way we are connected. I would like to be part of something big or be the big deal!

K

Comments


Here you can leave us commments. Let us know what you think about this code tutorial!

0 / 300

TRENDING POST
1
2
3
4
5
VISITORS
Online Users: 12
Recent Members: sahjahan, fk khan, Proper, Jenisha, Mr Joseph Charles
advertisement 2