public getHumanCreatedAt ( ) : boolean | string | ||
return | boolean | string |
public function getHumanCreatedAt()
{
$diff = time() - $this->created_at;
if ($diff > 86400 * 30) {
return date('M \'y', $this->created_at);
} else {
if ($diff > 86400) {
return (int) ($diff / 86400) . 'd ago';
} else {
if ($diff > 3600) {
return (int) ($diff / 3600) . 'h ago';
} else {
return (int) ($diff / 60) . 'm ago';
}
}
}
}
protected function createPostArray(Posts $post) { return ['slug' => "discussion/{$post->id}/{$post->slug}", 'title' => $post->title, 'created' => $post->getHumanCreatedAt()]; }