python - Substract epoch time from datatime.datatime.now -
this question has answer here:
- convert python datetime epoch strftime 5 answers
i asked value of key json on particular website , subtract value .now
(it's expiration date).
i'm doing using requests.get
json.load
. problem is: value i'm getting epoch time , datetime.datetime.now
not.
what's easiest way (datetime.datetime.now - key(epoch value)
)? see values in screenshot below. i've tried converting epoch "human date" subtraction nope.
edit: may not duplicate because asks processing timestamp , wants number of seconds between timestamp , now.
you did easiest. when timestamp involved think of arrow library.
>>> time_string = '2017-08-14 11:52:09.145000' >>> import arrow >>> time_diff = arrow.now()-arrow.get(time_string) >>> time_diff.total_seconds() 17604.346025
Comments
Post a Comment