Managing Timezone Settings

Managing Timezone Data

All platform-managed containers use UTC by default. The timezone can be changed for a complete environment through the TimeZone Change add-on or configured manually for Java and PHP application servers.

TimeZone Change Add-On

1Check the current timezone

Connect to the target container and run:

date
UTC timezone before change
New platform-managed containers use UTC by default.

2Import the add-on

Copy the TimeZone Change manifest.jps link from the JPS Collection and import it through the dashboard.

Import TimeZone Change add-on
Import the add-on using its JPS manifest URL.

Depending on the hosting provider, the add-on may also be available directly in Marketplace.

TimeZone Change in Marketplace
Install the add-on from Marketplace when provided by the hosting platform.

3Select the timezone

Choose the target environment, enter the required timezone name, and click Install.

Install TimeZone Change add-on
Select the environment and enter a timezone such as America/New_York.

4Verify the change

Run date again after installation.

Timezone after change
The example container has changed from UTC to EDT.

Update Java Timezone Data

Java compute nodes include a TZdata package. Older containers may require a manual update when timezone rules change.

1Connect through Web SSH

Web SSH button
Open a Web SSH session for the Java node.

Check the installed TZdata version:

java -jar /usr/java/utils/tzupdater.jar -V
Check Java TZdata version
Review the current Java timezone-data version.

Update the timezone package when necessary:

java -jar /usr/java/utils/tzupdater.jar -u
Update Java TZdata
Run the embedded TZUpdater to retrieve current timezone rules.

Change Java Timezone

To display the current server time on Tomcat, replace /opt/tomcat/webapps/ROOT/index.jsp with:

<%@page import="java.util.*"%>
<html>
  <head>
    <title>TZ Page</title>
  </head>
  <body>
    <%=new Date(System.currentTimeMillis()).toString()%>
  </body>
</html>
Java time test page
Create a simple JSP page to display the active server timezone.
Java time in UTC
The test page initially shows UTC.

For Tomcat, TomEE, Payara, Spring Boot, and Jetty, add the following JVM option to the relevant variables.conf file:

-Duser.timezone=US/Pacific
Application ServerConfiguration File
Tomcat 7, 8, 9 and TomEE/opt/tomcat/conf/variables.conf
Jetty 9/opt/jetty/etc/variables.conf
Payara 4 and 5/opt/payara/glassfish/domains/domain1/config/variables.conf
Spring Boot 1 and 2/opt/shared/conf/variables.conf
Timezone variable in variables.conf
Add the user.timezone JVM option to variables.conf.

For GlassFish, open the administration panel and add the same JVM option under Configurations > gfcluster-config or server-config > JVM Settings > JVM Options.

GlassFish timezone option
Add the timezone as a GlassFish JVM option.

For WildFly, edit /opt/wildfly/bin/standalone.conf, or /opt/wildfly/bin/domain.conf for a horizontally scaled server:

export JAVA_OPTS="-Duser.timezone=US/Pacific"
WildFly timezone configuration
Declare the timezone in WildFly JAVA_OPTS.

Save the changes and restart the application server.

Java time in PDT
The refreshed test page shows the updated Java timezone.

Check PHP Timezone Data

PHP timezone settings are managed in the [date] section of php.ini.

PHP date settings
Open the date section in php.ini.

When the internal timezone database is outdated, enable the external Olson database by removing the leading semicolon from the timezone extension line, then save and restart the PHP server.

Enable external PHP timezone database
Uncomment the timezone database extension.

Open phpinfo() and review its date section to confirm the active timezone database.

PHP timezone database information
Verify the timezone database version and default timezone.

Change PHP Timezone

To display the current PHP server time, replace /var/www/webroot/ROOT/index.php with:

<?php
echo date("h:i:sa");
?>
PHP timezone test page
Create a simple PHP page to display the server time.
PHP time in UTC
The initial PHP output uses UTC.

Set the required timezone in php.ini, for example:

date.timezone = Australia/Sydney
Change PHP timezone
Set the required date.timezone value.

Save the configuration, restart the PHP node, and refresh the test page.

PHP time after timezone change
The PHP application now displays the selected local time.
Restart required: Java and PHP timezone changes normally require restarting the corresponding application-server node before the new settings become active.

What’s next?