如何将UTC时间转换为PST时间?

san*_*nde 4 sql sqlite

我的表有 UTC 时区的日期列。我想将数据转换为 PST。这个怎么做?

世界标准时间:

日期
2017-06-26 17:35:47.0
2017-06-26 17:35:51.0
2017-06-26 17:28:04.0
2017-06-26 17:35:51.0
2017-06-26 17:35:45.0
2017-06-26 17:35:51.0
2017-06-26 17:35:51.0
2017-06-26 17:35:27.0
2017-06-26 17:35:27.0
2017-06-26 17:35:51.0
2017-06-26 17:35:51.0
2017-06-26 17:35:51.0
2017-06-26 17:35:51.0

Fat*_*n P 6

对于test_tabledate_column包含日期时间的表,要从 UTC 获取本地时间,您可以使用:

SELECT datetime(date_column,'localtime') as local_time from test_table;
Run Code Online (Sandbox Code Playgroud)

IST 示例(UTC 比 IST 晚 5 小时 30 分钟):

SELECT datetime(date_column||"-05:30") as local_time from test_table;
Run Code Online (Sandbox Code Playgroud)

  • 我以为|| 用于字符串连接而不是日期时间算术。您能解释一下吗? (3认同)