NodeJS return time in UTC. (0.00) as I understand there are two ways to store/set default timezone for NodeJS.First set in code using process.env.tz. another one is set date default timezone while you start the server.1.set in code using process.env.tz sample below
1 | process.env.TZ = 'Asia/Calcutta' |
2. another way is to set timezone while you run server js.PM2 is best for making NodeJS to production.Here I show you how to set NodeJS environment and timezone while run the server using pm2
NODE_ENV=production TZ= 'Asia/Calcutta' pm2 start app.js --name [PROJECT_NAME] |
In the above example, I use NODE_ENV to setting your environment. Like production, testing, development.TZ use to set as default timezone for NodeJS.PM2 start app.js use to start app.js.–name [project_name] use for giving naming convention to this process while I checklist of PM2 services status at that time its useful.