12-17-2021 09:22
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

12-17-2021 09:22
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Hey,
I'm currently creating yet another clock and I need to show the current time in a label based on a toggle in my settings page.
Sounds easy but my clock granularity is set to minutes so my user would have to wait up to ~59 seconds to see the changes.
Is there any way to kinda fire a new tick event programatically?
Best regards,
wrnr
Answered! Go to the Best Answer.

- Labels:
-
JavaScript
Accepted Solutions
12-17-2021 11:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


12-17-2021 11:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
There are many ways; here's mine. You can direct the clock.ontick event handler to a named function like this:
clock.ontick = evt => {onTick(evt.date)}
You declare your handler function like this:
function onTick(now) {...
When you need that function to run because you've changed something on which it depends (eg, setting):
onTick(new Date())
Gondwana Software
12-17-2021 11:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


12-17-2021 11:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
There are many ways; here's mine. You can direct the clock.ontick event handler to a named function like this:
clock.ontick = evt => {onTick(evt.date)}
You declare your handler function like this:
function onTick(now) {...
When you need that function to run because you've changed something on which it depends (eg, setting):
onTick(new Date())
Gondwana Software
12-17-2021 13:58
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

12-17-2021 13:58
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Thank you! This works
