raphaelb / timezones
Carbon包装器,用于在Laravel中轻松实现时区功能。
v1.4.1
2017-07-09 15:00 UTC
Requires
- php: >=5.6.0
- nesbot/carbon: ~1.0
Requires (Dev)
- mockery/mockery: ^0.9.4
- orchestra/testbench: ~3.0
- phpunit/phpunit: 5.*
- scrutinizer/ocular: ~1.3
- squizlabs/php_codesniffer: ~3.0
This package is not auto-updated.
Last update: 2024-09-14 18:47:37 UTC
README
Laravel包,提供轻松的时区功能。
为那些只想轻松处理时区的人所制作。
Composer要求
"raphaelb/timezones": "~1.4"
Laravel
Raphaelb\Timezones\TimezonesServiceProvider::class, 'Timezones' => Raphaelb\Timezones\Facades\Timezones::class use Raphaelb\Timezones\Facades\Timezones;
示例
class User { // Accessors in model class. /** * Get created_at attr. * @param $date * @return string */ public function getCreatedAtAttribute($date) { return app('timezones') ->toTimezone($date, 'gmt') ->format('d-m-Y H:i:s'); } /** * Get updated_at attr. * * @param $date * @return string */ public function getUpdatedAtAttribute($date) { return app('timezones') ->toTimezone($date, 'gmt') ->format('d-m-Y H:i:s'); } /** * Or inject a format when you know the given one. * Otherwise Carbon will fail. */ public function time() { // Constructor accepts a different format for your needs. $time = new Timezones('m-d-Y H:i:s'); return $time->toTimezone('09-03-2016 16:00:00', 'EST'); } }