All threads / How to create a live countdown clock?
Ask A Question

Notifications

You’re not receiving notifications from this thread.

How to create a live countdown clock?

Thomas Van Holder asked in General

Hi all,

We're creating an online auction which has a countdown clock on the show page of a listing.
The timer counts down every second, just like this example: https://countingdownto.com/
I've been looking at Stimulus Reflex, classic JS and action cable.
What's the best way to build this with rails?

Thanks for your feedback.

Hi Thomas,

I'm looking to do the same, did you find a solution?

Hi Samuel,

I've ended up using vanilla JS. However, you could do the same with Stimulus, that's what I would do when rebuilding it.

Here's roughly the outline of the code that was used.
https://gist.github.com/thomasvanholder/1778df30141e4c47362102518930c043

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 54,919+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2021 GoRails, LLC. All rights reserved.