Page 1 of 1

Getting date/time according to user time for PostgreSQL

Posted: Thu Jul 26, 2007 11:29 pm
by yisheng
Hi,

I'm trying to retrieve and displaying date and time of post according to user timezone.
Such as this forum showing the date and time of post.

I have done this in MySQL before -

Code: Select all

SELECT CONVERT_TZ(NOW(), sometable.server_time, sometable.user_time) AS user_time_now FROM sometable
Is there a way to do this in PostgreSQL?

Thanks in advance.

Posted: Fri Jul 27, 2007 2:51 am
by yisheng
Ok, i just found this

Code: Select all

SELECT (NOW() + justify_interval(interval '+1 hour') - justify_interval(interval '+4 hour')) FROM sometable
Asumming +1 hour is user timezone and +4 hour is server timezone.

Is this a good way to retrieve user time?