Foren

Time Zone Best Practices?

Eric Scheie, geändert vor 17 Jahren.

Time Zone Best Practices?

New Member Beitrag: 1 Beitrittsdatum: 31.01.07 Neueste Beiträge
We are developing a set of portlets that need to display dates and times to end users. I've noticed that in the the default configuration of liferay, user.timezone is always set to GMT time. This is from system.properties:


#
# The time zone must be set GMT so that the portal knows how to properly
# translate time across time zones.
#
user.timezone=GMT


If the portal is only accessed locally then portlets would not need to worry about converting time and date for display if liferay ran with the local time zone. So does liferay really have to run at GMT time?

Within the Admin portlet Enterprise configuration screen and also within user preferences there is a place for the Time Zone to be configured. What are these settings for? Should and can a portlet check these values before displaying a time in the user's local time?

Also, when using a MySQL database, does the default Time Zone for MySQL also have to be the same as the liferay portal (e.g. GMT)?

Thanks,

-Eric
thumbnail
Konstantin Rudy, geändert vor 14 Jahren.

RE: Time Zone Best Practices?

New Member Beiträge: 14 Beitrittsdatum: 28.09.09 Neueste Beiträge
Hello, I have the same question.

Is there an opportunity to display time in the timezone of the client without setting it hardcodingly to the properties of the portal.

Thanks in advance
whyBish valid, geändert vor 14 Jahren.

RE: Time Zone Best Practices?

Junior Member Beiträge: 63 Beitrittsdatum: 10.07.09 Neueste Beiträge
Any answers?
thumbnail
Jairo Luna, geändert vor 12 Jahren.

RE: Time Zone Best Practices?

Junior Member Beiträge: 57 Beitrittsdatum: 21.07.10 Neueste Beiträge
Any answers?
thumbnail
Hitoshi Ozawa, geändert vor 12 Jahren.

RE: Time Zone Best Practices?

Liferay Legend Beiträge: 7942 Beitrittsdatum: 24.03.10 Neueste Beiträge
Within the Admin portlet Enterprise configuration screen and also within user preferences there is a place for the Time Zone to be configured. What are these settings for? Should and can a portlet check these values before displaying a time in the user's local time?


Control Panel -> Portal Settings -> Display Settings -> Time Zone is to set the default portal instance time zone.

Control Panel -> Users -> Display Settings -> Time Zone is to set the default user's time zone. A portal may reside in a different time zone from where the user is using.

I think the Display Settings were made to select language and time to enable these to be changed for each user.

On this forum, there is a "Settings" on the top right corner where these settings can be set, but it doesn't seems to be working.
thumbnail
Neetu Mishra, geändert vor 9 Jahren.

RE: Time Zone Best Practices?

Junior Member Beiträge: 75 Beitrittsdatum: 21.05.12 Neueste Beiträge
Eric Scheie:
We are developing a set of portlets that need to display dates and times to end users. I've noticed that in the the default configuration of liferay, user.timezone is always set to GMT time.

Hi Eric,

To set the default timezone create/update "system-ext.properties" and set the default time zone
Eg.user.timezone=Australia/Perth

When Liferay starts for the first time, it creates a default user for the company. This user is assigned the time zone obtained from "system.properties" and the value of "user.timezone".

The data stored for the default user can be viewed by running this SQL snippet:
select * from User_ where defaultuser = 1;

The default user is not visible in the Control Panel but it is possible to edit the default user's time zone using "Control Panel > Portal > Settings > Miscellaneous > Display Settings > Time Zone".

Whenever a new user is created, it is assigned the current time zone of the default user, irrespective of the current value of the "user.timezone" system property.

If Liferay has already been installed, it will be configured with previous "user.timezone" and "user.locale" settings.

These values are typically "user.timezone=GMT" and "user.locale=en_US".

You can update these values for your required timezone and locale by running these SQL snippets against your Liferay database instance:

eg. update only default user timezones to Perth, Western Australia

update User_ set timezoneid = 'Australia/Perth' where defaultuser = 1;

For more info you can see wiki for this:
https://www.liferay.com/community/wiki/-/wiki/Main/Configure+time+zones+and+locale#section-Configure+time+zones+and+locale-How+to+set+the+default+timezone

Hope this will help you. emoticon

Regards,
Neetu
thumbnail
David H Nebinger, geändert vor 9 Jahren.

RE: Time Zone Best Practices?

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
Another zombie thread brought to life...

Neetu Mishra:
To set the default timezone create/update "system-ext.properties" and set the default time zone
Eg.user.timezone=Australia/Perth


This is only a good idea if all of your users are in the same timezone.

If you are serving multiple timezones, there is extra complexity involved in transforming from one TZ to another.

If you stick with GMT, then it is easy to convert from GMT to end user's timezone. Not just for Liferay times, but also for times that you manage for your own portlets.