K
K
Kwad2020-08-05 12:44:29
Python
Kwad, 2020-08-05 12:44:29

How to display unix timestamp today(now) and 24 hours ago?

Good afternoon, you need to somehow display the time now and 24 hours ago? How to do it?

int(time.time()) - displays the time now, but how to find out the time 24 hours from this point?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
milssky, 2020-08-05
@milssky

For example, subtract the number of seconds in a day from time.time()

now = time.time()
res = now - (24 * 60 * 60)
time.ctime(now)
'Wed Aug  5 12:57:04 2020'
time.ctime(res)
'Tue Aug  4 12:57:04 2020'

D
Dimonchik, 2020-08-05
@dimonchik2013

datetime timedelta
but it's easier to subtract seconds

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question