Laranudge logo
Dashboard

Manage your nudges with skill

Craft a nudge

Submit a new one to guide the way

Most loved nudges

The most popular nudges

Profile

Tend to your profile with finesse

Diff For Humans

Sometimes, the diffForHumans function on your models needs a slight modification and therefore, you feel like tweaking its output a bit.

Here's what you can easily do to amend it.

        
1$model->date_field->diffForHumans(); // 1 week ago
2$model->date_field->diffForHumans(['parts' => 2]); // 1 week 1 day ago
3$model->date_field->diffForHumans(['parts' => 3, 'join' => ', ']); // 1 week, 1 day, 15 hours ago
4 
5$model->diffForHumans([
6 'parts' => 3,
7 'join' => ', ',
8 'short' => true,
9]);
10// 1w, 1d, 15h ago
11 
12// For a better return (my favorite one).
13$model->date_field->diffForHumans([
14 'options' => Carbon::JUST_NOW | Carbon::ONE_DAY_WORDS | Carbon::TWO_DAY_WORDS
15]);
16// before yesterday
1
This splendiferous nudge was posted 1 month ago