Django postgres different values

Hi Django + Postgresql While studying aware datetime, I had a question and asked a question.

Postgresql document

For timestamp with time zone, the internally stored value is always in UTC (Universal Coordinated Time, traditionally known as Greenwich Mean Time, GMT). An input value that has an explicit time zone specified is converted to UTC using the appropriate offset for that time zone. If no time zone is stated in the input string, then it is assumed to be in the time zone indicated by the system's TimeZone parameter, and is converted to UTC using the offset for the timezone zone.

  1. Are you changing only the output differently according to the timezone setting value? (internally stored value is UTC ?)

SET TIME ZONE 'KST' (Asia/Seoul +9)

  1. Why is the same query but different values?

Django Settings

TIME_ZONE = "Asia/Bangkok" # ( +7 ) USE_TZ = False

Postgres Settings

SET TIME ZONE 'KST' (Asia/Seoul +9)

Django Server TimeZone

UTC

Django ORM Create Query

INSERT INTO "timezone_timezone" ("datetime") 
VALUES ('2022-11-22T01:58:14.373201'::timestamp) 
RETURNING "timezone_timezone"."id"; 
args=(datetime.datetime(2022, 11, 22, 1, 58, 14, 373201),)

psql select query

enter image description here

psql insert Django ORM Query

INSERT INTO "timezone_timezone" ("datetime") 
VALUES ('2022-11-22T01:58:14.373201'::timestamp) 
RETURNING "timezone_timezone"."id";

psql select query

enter image description here

Back to Top