How can I execute a bulk update of the time zone of all users?

Issue

After installing Liferay and creating all users, customer has realized that Liferay instance and all users are configured with the default timezone (UTC) but it should be updated to a correct one (ie: Europe/Paris)

Changing Liferay instance default timezone is explained in Locales and Encoding Configuration page but that change doesn't update existing users time zone.

A bulk update of the time zone of existing users is necessary.

Environment

  • DXP 7.0
  • DXP 7.1
  • DXP 7.2
  • Portal 6.0
  • Portal 6.1
  • Portal 6.2

Resolution

In order to execute a bulk update of the time zone of all users and Liferay instance default timezone:

  1. Pick a valid timeZoneId from "time.zones" property in portal.properties file:  https://github.com/liferay/liferay-portal/blob/70f2da48ea1b13794016df044dce38ecdc63ce75/portal-impl/src/portal.properties#L2826-L2867 (for example Europe/Paris)
  2. Stop all Liferay server nodes
  3. Backup database and Liferay environment before doing any change
  4. Execute following SQL updates (replace Europe/Paris with your own time zone)
    • update User_ set timeZoneId = 'Europe/Paris'
      update Calendar set timeZoneId = 'Europe/Paris'
  5. Start all Liferay server nodes

Important Notes:

  • You should never execute SQL updates directly to database unless Liferay Support Service ask you to do it.
  • Any custom development should always update database using Liferay API

Additional Information

You should always configure time zones at Liferay instance or users level, JVM should be always configured with UTC timezone.

There are two articles explains JVM time zone should be UTC:

If you want to change log time zone, it is possible to do it without changing JVM time zone:

这篇文章有帮助吗?
0 人中有 0 人觉得有帮助