Inserting and reading a `date` type field from different time zones. should time zones even be considered here?

折月煮酒 提交于 2020-06-01 07:52:11

问题


Working with Node, moment.js and PostgreSQL 9.6

  • It's 2020-01-24 00:00:00+00:00 and Client A (the writer) is at offset -06:00 and casually INSERTs a record with a date field in it, with value 2020-01-23, and thinks Well, this record will hold everything I need to store for date 2020-1-23 (their 2020-01-23)

  • Now it's 2020-01-24 00:20:00+00:00 and Client B (the reader) is at offset +11:00 and wants to see the information (from the same db and table) regarding 2020-01-24, BUT THERE IS NONE!! Because the writer, to the best of their knowledge, hasn't lived in 2020-01-24 yet.

    1. Should there be information available for the reader's 2020-01-24?
    2. How could time zone conversion be handled when querying and comparing dates in PG?
    3. Should we even think about time zones when only date fields are involved?
    4. Should date field be populated in a different manner?
    5. What is considered best practice in these scenarios?

Thanks

来源:https://stackoverflow.com/questions/60105450/inserting-and-reading-a-date-type-field-from-different-time-zones-should-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!