rj-clock displays configurable analog or digital clock widget. It is designed in the way that includes Daylight Saving Time Changes for Poland and United States. This plugin has been created for one of my commercial projects.
- Upload CSS, JS and IMG files to your project
- Add proper links to files in your HTML
- Check if url addresses for images are set properly for your project file system in CSS file (lines: 28, 32, 44, 48, 52)
- Add clock with configuration object in your HTML in a way presented in "Configuration" below
To add clock with complete configuration object use this code and configure it in a way displayed below snippet:
const clockName = new rjClock('parentElementId', {
type: 'analog',
style: 'dark',
seconds: true,
date: true
}).showTime(place, stdOffset);
The code presented above contains a configuration object. These are also default options so if you don't provide any of options when adding clock, clock will be added to your page with these options. Now lets get further information about every configuration options:
parentElementId
- in this place you must provide an id of HTML element in which the clock will be inserted (string)type
- clock type. You can choose betweendigital
andanalog
(string)style
- clock style. You can choose betweendark
andlight
(string)seconds
- choose whether the clock should display seconds or not -true
orfalse
(boolean)date
- choose whether the clock should display date or not -true
orfalse
(boolean)place
- choose clock for Poland -pl
or for United States -us
(string)stdOffset
- it should be provided when inplace
you have chosenus
. Explanation: in Poland there is one timezone in whole country. In United States this value varies (different states have different timezones). So you must decide for which state or city you display the time and accordingly - provide the timezone offset value for this place. e.g: Washington is UTC/GMT - 5 hours (in standard time) so in this example you setstdOffset
as-5
(number)
Final code for Washington:
const clockUS = new rjClock('us-clock', {
type: 'analog',
style: 'light',
seconds: true,
date: false
}).showTime('us', -5);
- JavaScript (ES5, ES6)
- CSS
- HTML
Finished