K
K
Kwad2020-02-15 01:49:15
JavaScript
Kwad, 2020-02-15 01:49:15

How to turn 3w3d12h12m40s into normal time?

Hello.
I receive an uptime from the API in this form: 3w3d12h12m40s
How can I convert this time into a normal form?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
ilyamst51, 2019-06-10
@DenKuzmin17

Instead of

var current = this.slider.parent().parent().parent().find('.active').eq(this.currentImg);
current.removeClass('active');

Write
var current = this.slider.parent().parent().parent().find('.active');
current.removeClass('active');

And that's it.

S
Sergey Sokolov, 2020-02-15
@Kwad

Not safe, but as an option without imports:

str1 = "3w3d12h12m40s"

seconds = 
  eval(
    str1
      .replace("w", "*86400*7+")
      .replace("d", "*86400+")
      .replace("h", "*3600+")
      .replace("m", "*60+")
      .replace("s", "")
  )

# 2117560

A
Andrey, 2020-02-15
@anerev

Here's how to break

import re
string = '3w3d12h12m40s'
string1 = re.findall(r'\d*.', strin)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question