0

I'm getting a hard time on change a timezone on AdonisJs 5.

PORT=8080
HOST=0.0.0.0
NODE_ENV=development
APP_KEY=blablablabla
DRIVE_DISK=local
TZ=America/New_York

I have tried the code above, but nothing changes.

Anyone have an idea on how to set the timezone ?

Harry Coder
  • 2,429
  • 2
  • 28
  • 32
Zeno Veiga
  • 61
  • 1
  • 2

2 Answers2

0

You need to change env.ts like this:

import Env from '@ioc:Adonis/Core/Env'

export default Env.rules({
  HOST: Env.schema.string({ format: 'host' }),
  PORT: Env.schema.number(),
  APP_KEY: Env.schema.string(),
  APP_NAME: Env.schema.string(),
  CACHE_VIEWS: Env.schema.boolean(),
  SESSION_DRIVER: Env.schema.string(),
  DRIVE_DISK: Env.schema.enum(['local'] as const),
  NODE_ENV: Env.schema.enum(['development', 'production', 'testing'] as const),
  TZ: Env.schema.string()
})

Add TZ Attribute.

Yi-Ju Wu
  • 41
  • 1
0

In database.js

mysql: {
client: 'mysql',
connection: {
  host: Env.get('DB_HOST', ''),
  port: Env.get('DB_PORT', ''),
  user: Env.get('DB_USER', ''),
  password: Env.get('DB_PASSWORD', ''),
  database: Env.get('DB_DATABASE', ''),
  timezone: 'America/New_York'
},
debug: Env.get('DB_DEBUG', false)}
FK Rima
  • 3
  • 4