How to insert datetime with timezone to SQLite?

前端 未结 1 1109
醉梦人生
醉梦人生 2021-01-17 12:37

I know that to insert a datetime this format yyyy-mm-dd hh:mm:ss should be used.

However my dataset has a timestamp field that looks like yyyy-mm-

相关标签:
1条回答
  • 2021-01-17 13:09

    SQLite's built-in date and time functions understand the timezone specification in these strings, but with different timezones, any other operations on these strings (even searches and comparisons) will not work correctly.

    If you want to handle time zones, you have to either

    • convert all timestamps to one specific time zone (UTC), so that you can use them for sorting and searching; or
    • leave the time zone information in there, but do all searching, sorting and other computations not in SQL but in your application.
    0 讨论(0)
提交回复
热议问题