2017-02-24 46 views

回答

0

我不知道,如果你還在尋找答案。在任何情況下,有人可能會通過搜索引擎找到這一點,所以這裏是一個想法:

import praw 
import datetime 

reddit = praw.Reddit(...) 
comment = reddit.comment(id="ctu29cb") 

now = int(datetime.datetime.timestamp(datetime.datetime.today())) 
then = int(comment.created) 
delta = now - then 

print("comment has been created with timestamp", then) 
print("which means on", datetime.datetime.fromtimestamp(then).strftime('%Y-%m-%d %H:%M:%S')) 
print("that was", delta, "seconds or", str(datetime.timedelta(seconds=delta)), "hours ago") 

返回

comment has been created with timestamp 1438924830 
which means on 2015-08-07 05:20:30 
that was 69533363 seconds or 804 days, 18:49:23 hours ago 
相關問題