winstonjs / winston-mongodb

A MongoDB transport for winston
https://github.com/winstonjs/winston-mongodb
295 stars 125 forks source link

how to change timezone #182

Open erwzqsdsdsf opened 3 years ago

erwzqsdsdsf commented 3 years ago

I set a env

export TZ='Asia/Shanghai'

node default log datetime is ok

but winston-mongodb still utc 0.

I set ubuntu sys utc use localtime ,but t winston-mongodb still utc 0.

yurijmikhalevich commented 3 years ago

@erwzqsdsdsf hi. What do you mean by UTC 0? Do you have incorrect timestamps or do you have correct timestamps saved (before you did anything to switch timestamp) and displayed in UTC 0?

aPhoneixCat commented 1 month ago

Actually, it's related to MongoDB, https://www.mongodb.com/docs/v4.4/tutorial/model-time-data/

MongoDB stores times in UTC by default, and will convert any local time representations into this form. Applications that must operate or report on some unmodified local time value may store the time zone alongside the UTC timestamp, and compute the original local time in their application logic.