Re: Retrieving current date

Started by sivapostgres@yahoo.com10 months ago5 messagesgeneral
Jump to latest
#1sivapostgres@yahoo.com
sivapostgres@yahoo.com

Hello,May be a very basic question.  We all here are new to Linux / PostgreSQL
Ubuntu Server 22.04PostgreSQL 15PgAdmin4 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?
Happiness Always
BKR Sivaprakash

#2David G. Johnston
david.g.johnston@gmail.com
In reply to: sivapostgres@yahoo.com (#1)
Re: Retrieving current date

On Wednesday, June 18, 2025, sivapostgres@yahoo.com <sivapostgres@yahoo.com>
wrote:

How to change the setting(s), if any, to retrieve the current date and
time in IST?

https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-TIMEZONES

Not totally sure if that will or won’t impact how pgAdmin behaves but it is
how you tell the server where you are. Strongly advise using the full
formal name and not an abbreviation or offset.

David J.

#3Ron
ronljohnsonjr@gmail.com
In reply to: sivapostgres@yahoo.com (#1)
Re: Retrieving current date

On Thu, Jun 19, 2025 at 2:23 AM sivapostgres@yahoo.com <
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?

In addition, see what time zone the Linux server is at:

$ timedatectl | grep zone
Time zone: America/New_York (EDT, -0400)

--
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!

#4Adrian Klaver
adrian.klaver@aklaver.com
In reply to: sivapostgres@yahoo.com (#1)
Re: Retrieving current date

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

#5sivapostgres@yahoo.com
sivapostgres@yahoo.com
In reply to: Adrian Klaver (#4)
Re: Retrieving current date

Thanks all,
I just changed the timezone setting in postgresql.conf file.  That resolved this issue.

On Thursday 19 June, 2025 at 07:41:16 pm IST, Adrian Klaver <adrian.klaver@aklaver.com> wrote:

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