在除錯模式下使用 vscode,當我將滑鼠懸停在日期欄位上時,它顯示如下圖。

但是當我注銷時,它被轉換為
"execution_date":"2021-12-02T20:23:48.322Z"
這是負 7 小時。該欄位作為時間戳存盤在 AWS RDS 上的 postgres 資料庫中,運行show timezone;回傳 UTC,我在 GMT 7 時間使用 VSCode。我該如何解決這個問題,因為日期已更改并用于呼叫 api,因此回傳的結果將不正確。
uj5u.com熱心網友回復:
這不是一個完整的答案,因為這將取決于更多資訊。相反,它是對正在發生的事情的解釋,可以幫助您進行故障排除:
set TimeZone = UTC;
show timezone;
TimeZone
----------
UTC
--Show that timestamp is taken at UTC
select now();
now
-------------------------------
2021-12-05 18:23:38.604681 00
--Table with timestamp and timestamptz to show different behavior.
create table dt_test(id integer, ts_fld timestamp, tsz_fld timestamptz);
--Insert local time 'ICT'
insert into dt_test values (1, '2021-12-03 03:23:48.322 07', '2021-12-03 03:23:48.322 07');
--The timestamp entry ignores the time zone offset, while the timestamptz uses it to rotate to UTC as '2021-12-03 03:23:48.322 07' is same as '2021-12-02 20:23:48.322 00'
select * from dt_test ;
id | ts_fld | tsz_fld
---- ------------------------- ----------------------------
1 | 2021-12-03 03:23:48.322 | 2021-12-02 20:23:48.322 00
--timestamp takes the value as at 'ICT' and then rotates it to the current 'TimeZone' UTC. The timestamptz takes the value at UTC at rotates it to 'ICT'
select ts_fld AT TIME ZONE 'ICT', tsz_fld AT TIME ZONE 'ICT' from dt_test ;
timezone | timezone
---------------------------- -------------------------
2021-12-02 20:23:48.322 00 | 2021-12-03 03:23:48.322
我猜測在獲取 API 值的程序中的某個時刻,代碼正在獲取該timestamp值并AT TIME ZONE 'ICT'使用某些等效程式在資料庫中或下游應用。
uj5u.com熱心網友回復:
我發現了問題,它與 Sequelize 和 postgres 如何處理timestamp without timezone. 如果你有和我一樣的問題,請參考以下鏈接:https : //github.com/sequelize/sequelize/issues/3000
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/374894.html
標籤:PostgreSQL的 日期 约会时间 视觉工作室代码 时间
上一篇:RobotFrameWork:有沒有辦法在運行暫停的情況下檢查report.html?
下一篇:更改日期/時間單元格中的時間
