Digital Clock Using JavaScript
Today we will discuss about how to create a digital clock on your website. It is little bit easier task. We can use Javascript for this task. Create a file time.html on your _includes directory. The time.html is looks like this. You can change styles according to your perspective.
<center>
<style>
#clock{
color:#5bb66f;
display:inline;
}
</style>
<script>
function digclock()
{
var d = new Date()
var t = d.toLocaleTimeString()
document.getElementById("clock").innerHTML = t
}
setInterval(function(){digclock()},1000)
</script>
<font color=#5bb66f>Now: </font><div id="clock">
</div>
In the seventeenth line of your code you can see a Now:. The same thing you can see at the footer of this site. If there is no display:inline;on the style, the time and Now: displayed on the different lines. The 1 sec. delay is produced using setInterval(function(){digclock()},1000) which gives 1000 milli second or 1 second delay. While var t = d.toLocaleTimeString() returns the time portion of a Date object as a string, using locale conventions. I am not going to more technical detaild. If you have any doubt w3schools will be a greate tutor for you… Most probably your theme have a footer.html file. Open that file and include time.html using {% include time.html %}. Like this you can add this time.html on the header, footer, post, page… anywhereelse.
Hai friends. My name is Arun K Soman. I am from India. Now I am pursuing M.Sc. Electronics science degree from Cochin University of Science and Technoloy(CUSAT). I completed B.Sc Electronics from BPC college, Piravom. I am not a webdesigner. But I intersted in webdesigning. I have also some enthusiam in Electronics. I know how to use CSS kits like Bootstrap, w3.css etc. and HTML as well as Jekyll. This is not my first Jekyll template. I also created some jekyll templates before, But this is a full fledged one. This theme made with doing some tweaks on w3.css. It is fully open source under MIT Licence.Pull requests are welcomed to improve this theme.