V
V
val1n0r2020-02-25 01:34:37
JavaScript
val1n0r, 2020-02-25 01:34:37

How to organize a primitive countdown timer?

To all ku

There is a view that returns to the context the time until the completion of the action

Here is the line that gets the time in seconds until completion

portal_end_time = (portal_exp_time - datetime.datetime.now()).total_seconds()

I pass the portal_end_time variable to the function
def convert(seconds):
          seconds = seconds % (24 * 3600)
          hour = seconds // 3600
          seconds %= 3600
          minutes = seconds // 60
          seconds %= 60

          return "%d:%02d:%02d" % (hour, minutes, seconds)


And it, apparently, returns the formatted time. Example (01:33:36)

Since I don’t understand anything at all in JS, I would like to know how to organize a primitive timer that takes this string as input, well, or the number of seconds, and starts a countdown.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lloydbanks, 2020-02-25
@val1n0r

https://jsfiddle.net/lloydbanks/cwqgh03e/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question