获取评论发布后的时间 [Praw]
Get time since comment was posted [Praw]
有没有办法获取使用 Praw 发表评论后的时间?
我查看了文档,但找不到任何提及,如果没有,是否有任何解决方法来获得时间?
我不知道,如果你还在寻找答案。无论如何,有人可能会通过搜索引擎找到它,所以这里有一个想法:
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")
哪个returns
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
有没有办法获取使用 Praw 发表评论后的时间?
我查看了文档,但找不到任何提及,如果没有,是否有任何解决方法来获得时间?
我不知道,如果你还在寻找答案。无论如何,有人可能会通过搜索引擎找到它,所以这里有一个想法:
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")
哪个returns
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