Time zone for moment in a pod

9/25/2019

I am using the moment package, in an OpenShift cluster pod, to get current time stamp. E.g.

let info.timestamp = moment().tz(moment.tz.guess()).format('DD/MM/YYYY HH:mm:ss');

How do I pass the time zone as an environment variable for the pod so that moment().tz does not evaluate to UTC?

-- cogitoergosum
kubernetes-pod
momentjs
openshift
timezone

1 Answer

9/25/2019

Could you try the following configuration ? You can set a specific timezone to pod using TZ environment variable.

$ oc set env <deployment controller resource type> <the resource name> TZ=<timezone>

For example, if you use test deploymentconfig for your pod, you can set "Tokyo/Asia" timezone for you pod as follows.

$ oc set env dc/test TZ=Asia/Tokyo
-- Daein Park
Source: StackOverflow