python - Substract epoch time from datatime.datatime.now -


this question has answer here:

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.

see both values here datetime.datetime.now on top , epoch json on bottom

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

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -