“SQLALCHEMY Postgres Timestamp com fuso horário” Respostas de código

SQLALCHEMY Postgres Timestamp com fuso horário

from sqlalchemy import Column, DateTime, Integer, MetaData, Table
from sqlalchemy.sql import func

metadata = MetaData()

example = Table('example', metadata,
    Column('id', Integer, primary_key=True),
    Column('date', DateTime(timezone=True), default=func.now())
    )
Busy Boar

Timestamp com fuso horário Postgres

foo=> SET TIMEZONE TO 'Japan';
SET
foo=> SELECT '2011-01-01 00:00:00'::TIMESTAMP;
      timestamp      
---------------------
 2011-01-01 00:00:00
(1 row)

foo=> SELECT '2011-01-01 00:00:00'::TIMESTAMP WITH TIME ZONE;
      timestamptz       
------------------------
 2011-01-01 00:00:00+09
(1 row)

foo=> SELECT '2011-01-01 00:00:00+03'::TIMESTAMP;
      timestamp      
---------------------
 2011-01-01 00:00:00
(1 row)

foo=> SELECT '2011-01-01 00:00:00+03'::TIMESTAMP WITH TIME ZONE;
      timestamptz       
------------------------
 2011-01-01 06:00:00+09
(1 row)

foo=> SET TIMEZONE TO 'Australia/Melbourne';
SET
foo=> SELECT '2011-01-01 00:00:00'::TIMESTAMP;
      timestamp      
---------------------
 2011-01-01 00:00:00
(1 row)

foo=> SELECT '2011-01-01 00:00:00'::TIMESTAMP WITH TIME ZONE;
      timestamptz       
------------------------
 2011-01-01 00:00:00+11
(1 row)

foo=> SELECT '2011-01-01 00:00:00+03'::TIMESTAMP;
      timestamp      
---------------------
 2011-01-01 00:00:00
(1 row)

foo=> SELECT '2011-01-01 00:00:00+03'::TIMESTAMP WITH TIME ZONE;
      timestamptz       
------------------------
 2011-01-01 08:00:00+11
(1 row)
Nutty Nightingale

Respostas semelhantes a “SQLALCHEMY Postgres Timestamp com fuso horário”

Perguntas semelhantes a “SQLALCHEMY Postgres Timestamp com fuso horário”

Mais respostas relacionadas para “SQLALCHEMY Postgres Timestamp com fuso horário” em Sql

Procure respostas de código populares por idioma

Procurar outros idiomas de código