codewiser/laravel-cast-datetime-tz
最新稳定版本:v1.0.4
Composer 安装命令:
composer require codewiser/laravel-cast-datetime-tz
包简介
Cast datetime with timezone for Laravel
README 文档
README
Laravel doesn't respect timezone. Cast \Codewiser\Casts\AsDatetimeWithTZ fixes this wrong behaviour.
Before
class Article extends \Illuminate\Database\Eloquent\Model { protected $casts = [ 'date' => 'datetime' ]; }
// e.g. Laravel has Europe/London (+01:00) timezone config()->set('app.timezone', 'Europe/London'); $model = new Article(); $model->date = '2000-01-01T10:00:00+02:00'; echo $model->date->format('c'); // Expecting 2000-01-01T09:00:00+01:00 // Actual 2000-01-01T10:00:00+01:00
After
class Article extends \Illuminate\Database\Eloquent\Model { protected $casts = [ 'date' => \Codewiser\Casts\AsDatetimeWithTZ::class ]; }
// e.g. Laravel has Europe/London (+01:00) timezone config()->set('app.timezone', 'Europe/London'); $model = new Article(); $model->date = '2000-01-01T10:00:00+02:00'; echo $model->date->format('c'); // Expecting 2000-01-01T09:00:00+01:00 // Actual 2000-01-01T09:00:00+01:00
统计信息
- 总下载量: 726
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-06-01