localtime(0)

Started by Suresh Rajaover 11 years ago6 messagesgeneral
Jump to latest
#1Suresh Raja
suresh.rajaabc@gmail.com

Hi:

I'm using localtime(0) in various part of the function, and updating table
with the time. I use localtime at places like the start of the function and
at the end of the function. The function takes about 5 mins to run,. The
issue is that the function always print the same time for both start and
end. I'm trying to capture the time at various point of the function, but
it always print the same time. Is localtime(0) is not correct.

Thanks,
-SR

#2Rob Sargent
robjsargent@gmail.com
In reply to: Suresh Raja (#1)
Re: localtime(0)

On 12/29/2014 09:32 AM, Suresh Raja wrote:

Hi:

I'm using localtime(0) in various part of the function, and updating
table with the time. I use localtime at places like the start of the
function and at the end of the function. The function takes about 5
mins to run,. The issue is that the function always print the same
time for both start and end. I'm trying to capture the time at
various point of the function, but it always print the same time. Is
localtime(0) is not correct.

Thanks,
-SR

http://www.postgresql.org/docs/9.3/static/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT

#3Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Suresh Raja (#1)
Re: localtime(0)

On 12/29/2014 08:32 AM, Suresh Raja wrote:

Hi:

I'm using localtime(0) in various part of the function, and updating
table with the time. I use localtime at places like the start of the
function and at the end of the function. The function takes about 5 mins
to run,. The issue is that the function always print the same time for
both start and end. I'm trying to capture the time at various point of
the function, but it always print the same time. Is localtime(0) is not

See:

http://www.postgresql.org/docs/9.3/interactive/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT

In particular clock_timestamp()

correct.

Thanks,
-SR

--
Adrian Klaver
adrian.klaver@aklaver.com

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#4Suresh Raja
suresh.rajaabc@gmail.com
In reply to: Adrian Klaver (#3)
Re: localtime(0)

clock_timestamp() gives more than I need. i just need time, - no date, or
msec or timezone. How can i get to print the current time alone.

Thanks,

On Mon, Dec 29, 2014 at 10:41 AM, Adrian Klaver <adrian.klaver@aklaver.com>
wrote:

Show quoted text

On 12/29/2014 08:32 AM, Suresh Raja wrote:

Hi:

I'm using localtime(0) in various part of the function, and updating
table with the time. I use localtime at places like the start of the
function and at the end of the function. The function takes about 5 mins
to run,. The issue is that the function always print the same time for
both start and end. I'm trying to capture the time at various point of
the function, but it always print the same time. Is localtime(0) is not

See:

http://www.postgresql.org/docs/9.3/interactive/functions-datetime.html#
FUNCTIONS-DATETIME-CURRENT

In particular clock_timestamp()

correct.

Thanks,
-SR

--
Adrian Klaver
adrian.klaver@aklaver.com

In reply to: Suresh Raja (#4)
Re: localtime(0)

On 29/12/2014 17:25, Suresh Raja wrote:

clock_timestamp() gives more than I need. i just need time, - no date,
or msec or timezone. How can i get to print the current time alone.

Please don't top-post; the convention on this list is to bottom-post, as
it makes discussions easier to follow.

Depending on your needs, you could use to_char() to format the value of
clock_timestamp() as you wish. This outputs a string rather than a time
value, but would be fine for logging, say.

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#6Tom Lane
tgl@sss.pgh.pa.us
In reply to: Raymond O'Donnell (#5)
Re: localtime(0)

"Raymond O'Donnell" <rod@iol.ie> writes:

On 29/12/2014 17:25, Suresh Raja wrote:

clock_timestamp() gives more than I need. i just need time, - no date,
or msec or timezone. How can i get to print the current time alone.

Please don't top-post; the convention on this list is to bottom-post, as
it makes discussions easier to follow.

Depending on your needs, you could use to_char() to format the value of
clock_timestamp() as you wish. This outputs a string rather than a time
value, but would be fine for logging, say.

EXTRACT() might help, too.

regards, tom lane

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general