How to convert date time value in GMT to value in a specific time zone

As our application requirement, we have a date-time value in GMT that loaded from database, and we want to convert it to value in a specific time zone (example: America/Chicago).

  Discussion posts and replies are publicly visible

Parents Reply
  • +1
    Certified Lead Developer
    in reply to TrBaPhong

    This is tricky - when you run "datetime(2020,03,24,11,0,0)", i.e. from the expression rule editor, it interprets the resulting value already converted to your user preferred time zone, so then running local() on that result generates an incorrect value.  AFAIK this will behave differently if you run it directly on a value pulled from the DB.  Also I find that using the function "userdatetime()" in the expression rule editor causes more expected values to be shown.

    All of this depends pretty largely on your particular use case, and overall data source and format -- all I can say is that you should experiment in the expression rule editor with what different things cause different outputs, because I guarantee there's a way to get what you want, even if it's a little confusing to get there.

Children