S
S
shadowzxc2021-06-27 03:56:16
Python
shadowzxc, 2021-06-27 03:56:16

How to convert seconds with milliseconds to hours and minutes?

How to convert seconds with milliseconds to hours and minutes? discord.py
The code for which you need to convert:

@bot.event
async def on_voice_state_update(member, before, after):
    with open('c:/Python/TOXBOT/database.json', 'r', encoding = "utf-8") as file:
        data = json.load(file)
    if before.channel is None and after.channel is not None:
        t1 = time.time()
        data[str(member.id)]['Онлайн'] = t1
    elif before.channel is not None and after.channel is None and member.id in tdict:
        t2 = time.time() 
        print(t2-tdict[member.id])
        data[str(member.id)]['Онлайн'] + data[str(member.id)]
    with open('c:/Python/TOXBOT/database.json', 'w', encoding = "utf-8") as file:
        json.dump(data, file)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dimonchik, 2021-06-27
@dimonchik2013

https://stackoverflow.com/questions/35989666/conve...
there are more options with Human formatting
d = datetime.timedelta(milliseconds=418235000)
print d

O
o5a, 2021-06-27
@o5a

It's easier to use datetime.timedelta

...
t2 = time.time() 
delta = t2-tdict[member.id]
print(datetime.timedelta(seconds=delta))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question