How to configure the displayed time zones?

Issue

  • It is widely documented that Liferay does not recommend changing the JVM time zone and that I should leave it as GMT. (See references under Additional Information).
  • But me and my users are from different time zones so how do I make sure that the correct time is displayed for everyone?

Environment

  • Liferay DXP 7.0+

Resolution

  • As mentioned above, it is advised that you leave the JVM time zone as GMT at all times. This will be the standard based on which each date is stored in the portal's database. When the portal needs to display one stored date to the end users, the portal calculates the display date based on the current date of the application server (this date is affected by the configured JVM level time zone) and the stored GMT format date.
  • Then, you have the presentation layer settings. The time zones which will be available in the UI can be specified in the portal-ext.properties file, with this property:
    time.zones=
  • The specified IDs come from the class java.util.TimeZone so you can specify any Time Zone from the Available Time Zones list. For example, if you change Europe/Lisbon to Europe/London, "UTC+1 British Summer Time" appears instead of "UTC +1 Western European Summer Time" in the list of available time Zones in the UI.
  • Daylight Saving is taken into account automatically. If you select a Time Zone which recognizes Daylight Saving, Liferay will automatically adjust the times for users. This will be recognized from the OS's date and time. For example: In a test environment, select "UTC+2 Central European Summer Time" as a preferred display time for the Admin user's account. Stop Liferay and adjust the OS's date to November. When Liferay starts again, the times are adjusted correctly and the name of the selected Time Zone changes to "UTC+1 Central European Time".
  • The dates and times the user will see in the portal's UI will depend on the following selections:

    1. Instance Settings: default Instance time. For example, if the Calendar is viewed by a user who is not logged in, the Calendar displays events using the time zone set by the portal administrator in Instance Settings.
    2. The user's Account Settings: users who are logged in will see events according to their preferred time zones.
  • The way the Calendar widget works is a bit different because you can configure the user settings in the widget's Configuration menu and you can also configure the Time Zone for the different Calendars (eg: Liferay DXP).

Additional Information

Was this article helpful?
2 out of 2 found this helpful