我可以得到comment_date 有一个循环
它显示为2018-03-19 12:30:06.<来,我只想Last seen 格式
(例如,3 min ago , 1 hour ago , 1 day ago , 2 week ago )
我怎样才能做到这一点?
["comment_date"]=>
string(19) "2018-03-19 12:30:06"
["comment_date_gmt"]=>
string(19) "2018-03-19 12:30:06"
string(19)" \"2018-03-19="" 12:30:06\" [\"comment_date_gmt\"]="> string(19)" \"2018-03"="">
我可以得到comment_date 有一个循环
它显示为2018-03-19 12:30:06.<来,我只想Last seen 格式
(例如,3 min ago , 1 hour ago , 1 day ago , 2 week ago )
我怎样才能做到这一点?
["comment_date"]=>
string(19) "2018-03-19 12:30:06"
["comment_date_gmt"]=>
string(19) "2018-03-19 12:30:06"
WordPress的核心已经有了这样的功能。它被称为“human\\u time\\u diff”,用于WP管理部分。
用法非常简单:
echo human_time_diff( $from, $to );
其中,$from是差异开始的Unix时间戳,$to是结束时间差的Unix时间戳(默认情况下为time()。因此,您必须使用strotime函数将日期转换为时间戳。
在这里,您可以找到有关它的更多信息和一些示例:https://codex.wordpress.org/Function_Reference/human_time_diff
我在WordPress上发表评论时使用了Disqus。我认为我可以删除这一行是正确的,还是完全错了?我指的是:<?php comments_template(); ?> 我可能错了,否则评论怎么知道在哪里加载才对呢?