is there way set local timezone in laravel?
in config/app.php
'timezone' => 'utc', - what should added timezone value above uses local timezone?
after research, stumbled upon following php way of dealing it:
$usertimezone = auth::user()->timezone; date_default_timezone_set($usertimezone); // , change configuration match config::set('app.timezone', $usertimezone) but, there elegant solution other converting timezone using above code.
cheers
don't that. never set global laravel timezone user's timezone. you'll face endless problems.
choose application timezone, set laravel config timezone , never change it.
instead, when need show date in user's timezone like
user::find(1)->foobazed_at->timezone(auth::user()->timezone); to control model columns automatically converted carbon\carbon instances, add following method model file:
public function getdates() { return array('foobazed_at', static::created_at, static::updated_at, static::deleted_at); }
Comments
Post a Comment