samedi 22 janvier 2022

How can update Current Timezone in the main configuration?

config/app.php

'timezone' => 'America/New_York',

I'm trying to update my app.timezone base on clientTimeZone Asia/Kolkata

$date = new DateTime();
$timeZone = $date->getTimezone();
echo $timeZone->getName().PHP_EOL;

$timezone_offset_minutes = 330; 
$clientTimeZone = timezone_name_from_abbr("", $timezone_offset_minutes*60, false);
echo $clientTimeZone .PHP_EOL;

Session::put('clientTimeZone',$clientTimeZone);
config('app.timezone', $clientTimeZone);

$date = new DateTime();
$timeZone = $date->getTimezone();
echo $timeZone->getName() .PHP_EOL;

This is the result

America/New_York 
Asia/Kolkata 
America/New_York

I have a feeling that this

config('app.timezone', $clientTimeZone);

is not taking any effect



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3KDEvAO
via IFTTT

Aucun commentaire:

Enregistrer un commentaire