sukohi / clock-label
Laravel 包,用于管理时钟标签,如“本月”等。
2.0.0
2016-03-26 07:13 UTC
Requires
- laravel/framework: ~5.0
This package is not auto-updated.
Last update: 2024-09-14 18:47:41 UTC
README
Laravel 包,用于管理时钟标签,如 本月
等。
此包之前被称为 TimeLabel,使用 composer require
命令后出现错误。
安装
执行 composer 命令。
composer require sukohi/clock-label:2.*
在 app.php 中设置服务提供者
'providers' => [
...Others...,
Sukohi\ClockLabel\ClockLabelServiceProvider::class,
]
同时别名
'aliases' => [
...Others...,
'ClockLabel' => Sukohi\ClockLabel\Facades\ClockLabel::class
]
用法
$clock_label = ClockLabel::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_clocks = [
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_clocks as $dt) {
if($clock_label->isFirst($dt)) {
echo $clock_label->get($dt) .'<br>';
}
echo $dt .'<hr>';
}
许可证
本软件包采用 MIT 许可证授权。版权所有 2016 Sukohi Kuhoh