How do I show the local time zone along with timestamp instead of UTC

I want to show local time zone like IST, CST with date time .Now it is showing only UTC. In postgresql it is showing as IST but while execute the same query in appsmith it is showing as UTC.

@Ginjo can you share the query you are using?

Hi this is my query in postgresql

SELECT to_char( A.last_updated_date ,‘dd-mm-YYYY HH12:MI:SS AM TZ’) ) as last_updated_date
FROM customer_details A order by A.last_updated_date desc

@Ginjo Apologies for the late reply. I lost track of this one. Have you tried using at time zone For eg: something like SELECT "createdAt" at time zone 'UTC' at time zone 'Asia/Calcutta' FROM users;

@dancia Tried the above syntax but time showing incorrectly for this. Also in appsmith application it showing UTC again not local time zone.

For this query ,

SELECT to_char( A.last_updated_date ,‘dd-mm-YYYY HH12:MI:SS AM TZ’) ) as last_updated_date
FROM customer_details A order by A.last_updated_date desc

the result is as : 20-01-2022 02:26:41 PM IST in postgresql

but the same date is showing in application as : 20-01-2022 08:56:41 AM UTC.

@Ginjo Hey sorry you are still facing this issue. I checked with the team and they suggested using the moment() function like this moment().tz("America/Los_Angeles").format();

@dancia ok I will try it

@dancia Sorry for the delayed update. This problem is not solved yet. Can you suggest any other way ?

Hey @Ginjo, can you please check this answer on how you can convert timezones with moment? Meanwhile, I’ll try to build a sample app to do this on Appsmith.

I think we have a bug related to this and that’s probably why it isn’t working - [Bug] Locale conversion not working for moment · Issue #6445 · appsmithorg/appsmith · GitHub

@vihar let us know if you are able to find a workaround.

@dancia , @vihar thank you for the update. I am waiting for the solution.

As I mentioned above I got the correct format using postgres query . But while I am applying this in application , it showing the UTC format only.

@Ginjo can you please share the code you’re using to display the date and the date that is being returned in your postgres? If you could create a public sample app that shows this issue that would be great

@Nikhil I am already mentioned the code and the results above .

For this query ,

SELECT to_char( A.last_updated_date ,‘dd-mm-YYYY HH12:MI:SS AM TZ’) ) as last_updated_date
FROM customer_details A order by A.last_updated_date desc

the result is as : 20-01-2022 02:26:41 PM IST in postgresql

but the same date is showing in application as : 20-01-2022 08:56:41 AM UTC.

@Nikhil @dancia @vihar , Solved this issue with the help of Anand Srinivasan on discord . Thank you for your support.

Here is the code snippet :smiley:

moment(last_updated_date).local().format(‘MM-DD-YYYY hh:mm:ss A’).concat(’ '+moment.tz(moment.tz.guess()).format(“z”))

1 Like

@Ginjo Glad to hear that. Could you also share the solution here as that will help other users who face a similar issue :slight_smile: Thanks

1 Like