Thread: localtime(0)

localtime(0)

From
Suresh Raja
Date:
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

Re: localtime(0)

From
"Jonathan S. Katz"
Date:
Hi Suresh,

On Dec 29, 2014, at 11:31 AM, Suresh Raja <suresh.rajaabc@gmail.com> 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.

You probably want the "clock_timestamp()" function.  There is an explanation for all the PostgreSQL current date/timestamp functions here: http://www.postgresql.org/docs/current/static/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT

Best,

Jonathan

Re: localtime(0)

From
Rene Romero Benavides
Date:
Try  clock_timestamp() or timeofday()::timestamp

2014-12-29 10:31 GMT-06:00 Suresh 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




--
El genio es 1% inspiración y 99% transpiración.
Thomas Alva Edison
http://pglearn.blogspot.mx/