Closed. This question is off-topic. It is not currently accepting answers.
Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third party plugins and themes are off topic, they are better asked about at their developers’ support routes.
I could get comment_date with a loop.
And it shows like 2018-03-19 12:30:06 .
Here, I just want to get Last seen format.
(For instance, 3 min ago , 1 hour ago , 1 day ago , 2 week ago )
How can I achieve it?
["comment_date"]=>
string(19) "2018-03-19 12:30:06"
["comment_date_gmt"]=>
string(19) "2018-03-19 12:30:06"
WordPress already have such function in its core. It’s called ‘human_time_diff’ and it’s used in WP admin section.
Usage is pretty simple:
echo human_time_diff( $from, $to );
where $from is Unix timestamp from which the difference begins and $to is Unix timestamp to end the time difference (or time() by default).
So you’ll have to use strtotime function to convert date to timestamp.
Here you can find more info about it and some examples: https://codex.wordpress.org/Function_Reference/human_time_diff