| Package Data | |
|---|---|
| Maintainer Username: | Sukohi |
| Maintainer Contact: | capilano.sukohi@gmail.com (Sukohi) |
| Package Create Date: | 2015-10-17 |
| Package Last Update: | 2015-10-17 |
| Language: | PHP |
| License: | MIT |
| Last Refreshed: | 2025-10-26 03:12:13 |
| Package Statistics | |
|---|---|
| Total Downloads: | 17 |
| Monthly Downloads: | 0 |
| Daily Downloads: | 0 |
| Total Stars: | 1 |
| Total Watchers: | 1 |
| Total Forks: | 0 |
| Total Open Issues: | 0 |
Laravel package to manage time labels like This Month and so on.
Add this package name in composer.json
"require": {
"sukohi/time-label": "2.*"
}
Execute composer command.
composer update
Register the service provider in app.php
'providers' => [
...Others...,
Sukohi\TimeLabel\TimeLabelServiceProvider::class,
]
Also alias
'aliases' => [
...Others...,
'TimeLabel' => Sukohi\TimeLabel\Facades\TimeLabel::class
]
$time_label = TimeLabel::setLabel([
'today' => 'Today',
'yesterday' => 'Yesterday',
'this_month' => 'This Month',
'last_month' => 'Last Month',
'other' => 'M, Y' // You need to set date format only here.
]);
$date_times = [
Carbon::now(),
Carbon::now(),
Carbon::now()->subDay(),
Carbon::now()->subDay(),
Carbon::now()->subDays(2),
Carbon::now()->subDays(4),
Carbon::now()->subDays(4),
Carbon::now()->subDays(5),
Carbon::now()->subDays(10),
Carbon::now()->subDays(20),
Carbon::now()->subDays(50),
Carbon::now()->subDays(150),
];
foreach($date_times as $dt) {
if($time_label->isFirst($dt)) {
echo $time_label->get($dt) .'<br>';
}
echo $dt .'<hr>';
}
This package is licensed under the MIT License.
Copyright 2015 Sukohi Kuhoh