Re: Retrieving current date - Mailing list pgsql-general

From Adrian Klaver
Subject Re: Retrieving current date
Date
Msg-id 935dcc5f-0f78-4780-867e-8310b9f0d9fd@aklaver.com
Whole thread Raw
In response to Re: Retrieving current date  ("sivapostgres@yahoo.com" <sivapostgres@yahoo.com>)
Responses Re: Retrieving current date
List pgsql-general
On 6/18/25 23:23, sivapostgres@yahoo.com wrote:
> Hello,
> May be a very basic question.  We all here are new to Linux / PostgreSQL
> 
> Ubuntu Server 22.04
> PostgreSQL 15
> PgAdmin4 6.16
> 
> When I run the following query in pg_admin
> 
> Select today_now
> From   (Select localtimestamp(0) as today_now) a;
> 
> I get UTC time and not the IST time, which I expect.
> 
> How to change the setting(s), if any, to retrieve the current date and 
> time in IST?

For setting see:

https://www.postgresql.org/docs/current/runtime-config-client.html

"TimeZone (string)

     Sets the time zone for displaying and interpreting time stamps. The 
built-in default is GMT, but that is typically overridden in 
postgresql.conf; initdb will install a setting there corresponding to 
its system environment. See Section 8.5.3 for more information.
"

For a quick fix, maybe?:

select localtimestamp(0) at time zone 'Asia/Kolkata' as today_now;

> 
> Happiness Always
> BKR Sivaprakash
> 

-- 
Adrian Klaver
adrian.klaver@aklaver.com




pgsql-general by date:

Previous
From: Ron Johnson
Date:
Subject: Re: Retrieving current date
Next
From: Tomas Vondra
Date:
Subject: Re: Extension disappearing act