自从使用Praw发布评论以来,有没有办法获得时间?
我查看过这些文档但却找不到它,如果没有,是否有任何解决方法可以节省时间?
答案 0 :(得分: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