Is it possible to change default TimeZone in MongoDB using Rails 3?

前端 未结 2 970
无人共我
无人共我 2021-01-14 10:44

I have such trouble: when I\'m creating object and setting some datetime It is saving database in UTC TimeZone. Here is example:

//showing full list of objec         


        
相关标签:
2条回答
  • 2021-01-14 11:18

    You can change the timezone of your application so that ruby's date object will auto configure the dates. MongoDB will always store time in UTC.

    MongoDB has no internal knowledge of timezones.

    0 讨论(0)
  • 2021-01-14 11:28

    config.time_zone doesn't set "Server Time", that is controlled by your operating system usually.

    Rails always stores your dates in UTC in the database (unless you change a different setting).

    0 讨论(0)
提交回复
热议问题