简体   繁体   中英

How to convert UTC date of specific timezone to UTC +0 (default Greenwich)?

I want to insert an item to the DB in a specific date based on the client's timezone. So if client desired in today on 20:00, and his timezone is +3, I want that node and mongodb will set the date to be on today on 17:00. I hope that is clear enough.

Generally it is recommended to save all timestamps in database in UTC only, along with it you can save extra field timezone/offset value in each document. Check - https://docs.mongodb.com/manual/tutorial/model-time-data/

But if you want to save in local timezone, you need to do conversion at application level before inserting in database.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM