PostgreSQL
 sql >> Database >  >> RDS >> PostgreSQL

Imposta fuso orario personalizzato in Django/PostgreSQL (ora solare indiana)

Per l'India:

SELECT now() AT TIME ZONE 'Asia/Calcutta';
SELECT now()::timestamp AT TIME ZONE 'Asia/Kolkata';
SELECT now()::timestamp AT TIME ZONE '5:30';

Per il Nepal:

SELECT now()::timestamp AT TIME ZONE 'Asia/Katmandu';
SELECT now()::timestamp AT TIME ZONE 'NPT';

Per impostare il fuso orario per l'intera sessione:

SET time zone 'Asia/Calcutta';

Per reimpostarlo (sul fuso orario impostato in postgresql.conf:

RESET time zone;

Trova altro nelle viste di sistema pg_timezone_names e pg_timezone_abbrevs

SELECT *
FROM   pg_timezone_names
WHERE  utc_offset BETWEEN '05:00:00' AND '06:00:00'
ORDER  BY utc_offset;

SELECT *
FROM   pg_timezone_abbrevs
WHERE  utc_offset BETWEEN '05:00:00' AND '06:00:00'
ORDER  BY utc_offset;

Manuale di PostgreSQL su AT TIME ZONE costruire. Informazioni sui fusi orari .