Skip to main content
Participating Frequently
April 1, 2022
Question

Change Date and Time based on user time zone

  • April 1, 2022
  • 17 replies
  • 3 views

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

17 replies

mathieud0001
Brainy
April 1, 2022

Technically this should work out of the box if you are using the https://docs.appian.com/suite/help/22.1/Date_and_Time_Component.html without any manipulation.

Date should be stored as GMT in the database and is displayed according to the user's preferred timezone.

Participating Frequently
April 1, 2022

Hi Mathieu,

Thanks for the reply!

Tried by saving date as GMT, but it is resulting in some other date and time.

mathieud0001
Brainy
April 1, 2022

Not sure what you mean by "tried saving as GMT". You shouldn't have to transform it before saving.

mikes0011
Brainy
April 1, 2022

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).

The Expression Guru
Participating Frequently
April 1, 2022

Hi Mike,

Thanks for the reply!

I have tried with local(), but it is converting the time. 

mikes0011
Brainy
April 1, 2022

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?

The Expression Guru