Local time zone offset in PostgreSQL

前端 未结 2 897
礼貌的吻别
礼貌的吻别 2020-12-30 19:44

My web app stores all timestamps in UTC without time zones. I have a shell/psql script that returns a list of recent logins, and I want that script to display login times in

相关标签:
2条回答
  • 2020-12-30 20:28
    SELECT  current_setting('TIMEZONE')
    

    This can be used in a query, however, this does not give a numerical difference.

    Your solution is fine.

    0 讨论(0)
  • 2020-12-30 20:43

    To get # of seconds difference as an integer, I have used simply:

    select extract( timezone from now() );
    
    0 讨论(0)
提交回复
热议问题