jQuery Clock plugin: jClock
Jquery clock plug-in can be used to show local time or some other time zone rime very easily. Websites dealing with multiple locations or having offices at multiple locations can use this feature on their websites.
You just need to include the javascript file along with jquery which is the only dependency.
<script src="http://plugins.jquery.com/files/jquery.jclock-1.2.0.js.txt" type="text/javascript"></script>
Use following code to show clock on your website
<script type="text/javascript"> $(function($) { $('.jclock').jclock(); }); </script>
<div class="jclock"></div>
Use following code to show clock with some styling using options object.
<script type="text/javascript"> $(function($) { var options = { timeNotation: '12h', am_pm: true, fontFamily: 'Verdana, Times New Roman', fontSize: '20px', foreground: 'yellow', background: 'red' }; $('.jclock').jclock(options); }); </script>
<div class="jclock"></div>
Show UTC time
<script type="text/javascript"> $(function($) { var options = { utc: true }; $('.jclock').jclock(options); }); </script>
<div class="jclock"></div>
Show India time (using UTC offset)
<script type="text/javascript"> $(function($) { var options={ utc: true, utc_offset: 5.5 }; $('.jclock').jclock(options); }); </script>
<div class="jclock"></div>
India Time:
Possible options:- timeNotation (String): Type of time display: ’24h’ or ’12h’ (’12hh’ inserts leading 0). Default: ’24h’
- am_pm (Boolean): true/false. If true, displays A.M./P.M. Default: false (12h timeNotaion only)
- utc (Boolean): true/false. If true, shows time using UTC. Defaul: false
- utc_offset (Number): If specified, sets offset from UTC, negative or positive. Default: 0
- fontFamily (String): If specified, sets CSS fontFamily. Default: null
- fontSize (Number): If specified, sets CSS fontSize. Default: null
- foreground (String): If specified, sets CSS foreground color. Default: null
- background (String): If specified, sets CSS background color. Default: null
Most Commented Posts
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.
Comments
Very good tutorial to learn how to create a simple digital clock with javascript, i did not know baout that jclock js plugin, but hte fact that we can configure other time zones to display, is in fact a plus, thanks for sharing.
Is there any way to disable the display of seconds, as well as whether or not ‘AM/PM’ are displayed in caps or not? Thanks!
@Jonny
RE: “Is there any way to disable the display of seconds, as well as whether or not ‘AM/PM’ are displayed in caps or not? Thanks! “
Solution…
line 86 — var timeNow = hours + “:” + minutes; // + “:” + seconds;
this removes the seconds from the concatenation…
Cheers
look out one more clock plugin written in jquery, but the logic is borrowed from internet http://silibitest.unosofttech.com/jquery-clock/
I want to test the time before it is displayed to make the background change from red to green.
background: ” is empty for me at the moment.
I want it to use a jquery function to detirmine if it should be on (green) or off (red).
I wonder about opacity as well?
Anyone know the answer??
[...] reading a tweet about a clock plug-in, it made me think about how nifty it would be to have a copyright tool that could be used on sites [...]

[...] clock to your website is easy and you can use just javascript to create it on your web page. I have written a post on it where i used Jquery javascript library to do it. Adding better user interface for clock and [...]