Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set time zone offset? #97

Open
light0x00 opened this issue Nov 14, 2019 · 3 comments
Open

How to set time zone offset? #97

light0x00 opened this issue Nov 14, 2019 · 3 comments

Comments

@light0x00
Copy link

light0x00 commented Nov 14, 2019

ahhh, I know this is a naive question. but different date library has different rule, I usually use yyyy-MM-dd'T'HH:mm:ss+08 in other date libraries, but it doesn't work for this library . I'm a little confused.

i use a logging library named pino, It uses this library, and time zone is UTC+0, and I want to change it.
So i try to find answer in your document, and I found the following Setting, it seems to be what i want, but I don't know how to use it.

~ ~
o GMT/UTC timezone offset, e.g. -0500 or +0230.

What should I do?

@fatundem
Copy link

I have this same issue. Looking through the issues list now to see if it's been solved

@humblepie
Copy link

@light0x00 I also use pino with pino-pretty. The o mask pattern just prints out the current offset. It doesn't set an offset and change the output to local time if it was UTC. I wanted the log to display the time with local time zone. My app runs in docker so I achieved this with pino-pretty by doing the following:

  • set the environment variable -e "TZ=US/Central" on my docker container
  • set the pino-pretty option "translateTime" using the SYS: prefix "SYS:yyyy-mm-dd hh:MM:ss TT Z"

The timestamp entry ended up looking like this afterwards:
[2020-03-01 07:49:02 PM CST]

@N00nDay
Copy link

N00nDay commented Oct 28, 2021

@light0x00 I also use pino with pino-pretty. The o mask pattern just prints out the current offset. It doesn't set an offset and change the output to local time if it was UTC. I wanted the log to display the time with local time zone. My app runs in docker so I achieved this with pino-pretty by doing the following:

  • set the environment variable -e "TZ=US/Central" on my docker container
  • set the pino-pretty option "translateTime" using the SYS: prefix "SYS:yyyy-mm-dd hh:MM:ss TT Z"

The timestamp entry ended up looking like this afterwards: [2020-03-01 07:49:02 PM CST]

Adding SYS: before my date string did the trick for me. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants