Forms, fields and formulas

How do I show a date/time in a specific time zone, or get only the time part?

Rebuild the value with datetime() and a time zone name, shift it with offset(), and pull the time into a text field with toText() or hour().

How-to

Short answer: Use datetime() with a time zone name to show a value in that zone, or offset() to shift it. There's no time-only field, so capture a Date & time and extract the time into a text field.

Why it happens

  • Date and time display follows the account or user time zone setting.
  • Some system fields, such as _created_at, are stored and shown in GMT.

How to fix it

To show the submission time in another zone:

datetime(_submitted_at.year(), _submitted_at.month(), _submitted_at.day(), _submitted_at.hour(), _submitted_at.minute(), _submitted_at.second(), "Asia/Hong_Kong")

To shift a value by a fixed amount, use offset(), for example Date_Time_Field.offset(5, "h").

To get only the time:

  1. Add a Date & time field to capture the value.
  2. Add a text field with a formula such as Date_Time_Field.toText("hh:mm"), or use Date_Time_Field.hour() for the hour as a number.

To move Sundays to Monday, use weekDay(), which returns 1 for Sunday: if(Date_Field.weekDay() = 1, Date_Field + 1, Date_Field).

See date expressions and system fields.

Related answers