Quantcast
Channel: Live News for Yii Framework
Viewing all articles
Browse latest Browse all 2940

[wiki] change default date format in oracle

$
0
0

Default date format in oracle is DD-MON-RR (25-JAN-18). With that output, we can't using date formatting. Too solve this issue, we must change date format oracle like date commonly using ALTER SESSION SET NLS_DATE_FORMAT=...

For complete script ` return [

'class' => 'yii\db\Connection',
'dsn' => 'oci:host=127.0.0.1:1521/XE',
'username' => 'YOUR_USERNAME',
'password' => 'YOUR_PASSWORD',
'charset' => 'utf8',

// Schema cache options (for production environment)
//'enableSchemaCache' => true,
//'schemaCacheDuration' => 60,
//'schemaCache' => 'cache',

'on afterOpen' => function($event) {
    // $event->sender refers to the DB connection
    $event->sender->createCommand("ALTER SESSION SET NLS_DATE_FORMAT='DD-MM-YYYY hh24:mi:ss'")->execute();
}

]; `


Viewing all articles
Browse latest Browse all 2940

Trending Articles