I have install php-intl so that the date and time can be localized to my country. I set the timeZone in common/config/main.php as follow,
return [
'aliases' => [
'@bower' => '@vendor/bower-asset',
'@npm' => '@vendor/npm-asset',
],
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
'timeZone' => 'Asia/Jakarta',
...
in frontend/config/main.php, I have
…
‘formatter’ => [
‘class’ => ‘yii\i18n\Formatter’,
‘locale’ => ‘id-ID’,
‘defaultTimeZone’ => ‘Asia/Jakarta’,
‘nullDisplay’ => ‘’,
‘thousandSeparator’ => ‘.’,
‘decimalSeparator’ => ‘,’,
‘currencyCode’ => ‘Rp’
],
…
I save the datetime using
$model->stamp = date('Y-m-d H:i:s');
In my database it is save on mu timezone not UTC. However when I display it using
<?= Yii::$app->formatter->asDate($model->stamp 'php: j M y H:i:s'); ?>
I will have the stamp being displayed in 7 hour + the time of saved in database.
FYI, Jakarta is UTC +07:00
How could I correct this mistake?
TIA
Daniel