Hi All,
I have a use case where I need to convert Date and time based on user time zone.
I have a date and time component, and if user of timezone CDT selects date and time as "4/1/2022 11:46 AM CDT" and submits the case. If another user of time zone IST logs in then they should be able to see the date and time value as "4/1/2022 10:16 PM IST" (whatever the usertime zone is). Based on user time zone date and time value needs to be changed in UI.
I have tried with todatetime(), gmt() and usertimezone() functions but none of them works.
Please provide your suggestions.
Thanks
Discussion posts and replies are publicly visible
Generally speaking, Appian stores all datetimes internally as GMT, and casts them to a user's timezone in most (general) display scenarios. Thus usually you might not need to do much. In weirder cases, I've found the funciton "local()" is one of the more helpful ones for forcing things to display in a user's local time (but only when the source is something that wouldn't auto-convert).
Hi Mike,
Thanks for the reply!
I have tried with local(), but it is converting the time.
Well as I said, local() is only needed as an override in specific circumstances, which are hard to enumerate without specific examples. Could you provide some screenshots demonstrating what you're currently doing and what your users are seeing, versus what you think they should be seeing?
Am just using a simple date and time component, where the value is being stored as "4/1/2022 11:46 AM CDT" to DB. Here am using ri! as text datatype.
On retrieving the saved value from DB, I wanted the value to get changed according to userTime zone.
Will saving the value as Date and tIme datatype will solve this issue?
mpa17 said:as text datatype
Ah - yeah this is the sort of thing that should've been mentioned much earlier here. Why aren't you using the DateTime type already? This is basically exactly why we have that.
Yes.
I have a json format where I have only one column for value(which is of text datatype) to which I will be saving all the values.
Is there any way to achieve this in text datatype?
We could use a little more detail of course - like what your data structure looks like, how exactly you're capturing the datetime value and then converting it to json (and where the json is sourced from if there are any additional non-appian-input sources).
But based on testing i'm doing right now, it looks as if a dateTime value captured into an appian dateTime entry field and then stored into JSON text, automatically converts to GMT. If you're converting it back from JSON later to a dateTime data type, it should then automatically display in a user's chosen timezone, without much additional overriding necessary.
For example, am using a dateAndTime component and am using datatype of text to save it. On doing so, my value will get saved as "4/1/2022 11:46 AM CDT". On retrieving it from DB, the same value will be retrieved. Is there any way to save the dateTime value in GMT format(as am using Text datatype) to DB and retrieve it, so that based on usertime zone dateTime value will be changed.
Or is there any other way other than saving the value as GMT, any functions?
Can you share the expression / interface you have created? In general the converting works pretty well between different time zones, but I'm wondering if there is somewhere you are explicitly saving the time zone as text and that's why it isn't converting back and forth.
Hi Peter,
Please find the snippet below,
Here I have the value as "4/4/2022 10:43 AM CDT" which is in CDT timezone and am having it in Text datatype. I wanted this date and time to be converted based on user timezone. Now am currently in UK timezone, am expecting the value to be 4/4/2022 4:43 PM GMT+01:00, but my output is something else.