Ruk-Com PaaS Documentation

Build, deploy and operate applications on the platform.

RUK-COM PAAS / APPLICATION SETTINGS

Managing Timezone Settings

This guide is maintained for Ruk-Com PaaS. Screens and options may vary by platform version and account permissions.

Confirm the environment, region and account permissions, and back up current settings before changing a production system.

Managing Timezone Data

All containers created within the platform utilize the UTC timezone by default. However, in case of necessity, you can easily change it to any preferable one with the help of the TimeZone Change add-on. Follow the steps provided within the linked section to switch timezones on any of your instances.

Alternatively, you can apply the changes manually. For example, all of the Java and PHP application servers at the platform are supplied with special timezone packages, which includes data about the history of local time in different locations around the globe and current timezone rules. This information is required for software, running inside the appropriate containers, and is regularly updated within the corresponding server builds in the confines of the newly released platform versions.

Besides that, you can instantly update the timezone rules manually if necessary, or change the currently used TZ, based on the preferred location. So, below we’ll reveal some specifics of the timezone data management at the platform for the application servers of the programming languagesmentioned above:

TimeZone Change add-on can be installed on top of any of your environments, changing the timezone for all of the comprised containers in a matter of minutes.

  1. Before proceeding to installation, let’s check the timezone on our target container using the date command.

Image 1: date before timezone change As you can see, the UTC zone is used (default for all platform-managed containers).

Image 2: import timezone change add-on

Tip: Based on your particular hosting provider settings add-on can be available via platform Marketplace.

Image 3: marketplace timezone add-on

  1. Within the opened frame, select the target Environment and type the preferable TimeZone Name (list of time zones) for it.

Image 4: install timezone change add-on Click Install to apply changes.

  1. After add-on installation, you can verify the timezone change by running the date command one more time.

Image 5: date after timezone change As you can see, the system time was successfully switched to the EDT (Eastern Daylight Time).

Timezone Rules for Java

The timezone rules within Java compute nodes are delivered by means of the dedicated TZdata package, comprised in each appropriate container. Follow the instructions below to:

Updating Timezone Data

Despite the fact the newest TZdata package edition is integrated into a node during its creation, after some time it becomes outdated due to periodical changing of the intrinsic data. Thus, old containers may require the corresponding updating from time to time (particularly, in order not to be recreated each time this is needed). For that, a special embedded TZUpdater tool is used, intended for keeping your timezone data accurate and up-to-date. It is fairly simple to use and can be run with a single-line command; you just need to:

  1. Connect to your Java environment via SSH, e.g., using the embedded Web SSH client:

Image 8: Web SSH button 2. Once inside, you can check the currently used TZdata version by executing the following string:

bash

java -jar /usr/java/utils/tzupdater.jar -V

Image 9: check timezone rules version 3. If you’ve observed the corresponding package in the chosen container is outdated, you can update the timezone information using the embedded TZUpdater tool:

bash

java -jar /usr/java/utils/tzupdater.jar -u

Image 10: update server timezone As you can see, getting the latest timezone package version for Java-powered server is a really simple operation with the platform.

Changing Timezone Java

Now, let’s discover how to check and change the application server’s local time - we’ll consider this on the example of a Tomcat 9 server.

  1. Let’s set the current timestamp to be shown at the server start page - this will help to quickly ensure that new timezone settings have been successfully applied and are relevant for now.

For that, paste the code below instead of the /opt/tomcat/webapps/ROOT/index.jsp file default content (the easiest way is to use the inbuilt File Manager for that).

html

<%@page import="java.util.*"%>
<html>
   <head>
       <title>TZ Page</title>
   </head>
   <body>
       <%=new Date(System.currentTimeMillis()).toString()%>
   </body>
</html>

Image 12: Java check time app 2. Save the changes and Open your environment in browser with the corresponding button to see the current server time, like:

Image 13: Java time UTC 3. In order to change the actual timezone for a particular server, perform the following:

  • for Tomcat, TomEE, Payara, Spring Boot and Jetty Switch to the variables.conf configuration file and add the -Duser.timezone variable with the required zone as a value, for example: -Duser.timezone=US/Pacific

Note: Depending on a particular application server used, the location of this file may vary:

*   Tomcat 7, 8, 9, TomEE - _/opt/tomcat/conf/variables.conf_
*   Jetty 9 - _/opt/jetty/etc/variables.conf_
*   Payara 4, 5 - _/opt/payara/glassfish/domains/domain1/config/variables.conf_
*   Spring Boot 1, 2 - _/opt/shared/conf/variables.conf_

Image 14: variables.conf timezone variable * for GlassFish Access the GF admin panel, go to the Configurations > gfcluster-config (or server-config for GF 4) > JVM Settings > JVM Options section and click the Add JVM Option button. Paste the corresponding string (e.g., -Duser.timezone=US/Pacific) within the appeared input field:

Image 15: GlassFish timezone variable * for WildFly Switch to the /opt/wildfly/bin/standalone.conf file (or, if a server was scaled horizontally, refer to the /opt/wildfly/bin/domain.conf config) and declare the corresponding variable using the following format: export JAVA_OPTS="-Duser.timezone=US/Pacific"

Image 16: WildFly timezone variable

Save the made adjustment and Restart your application server in order to apply new settings.

  1. Now, just refresh the server start page or click Open in Browser again to see the updated local time:

Image 17: Java time PDT Great, new rules were applied successfully. In such a way, you can set any desired time location for your server without any problems, in a matter of minutes.

Timezone Rules for PHP

Managing of the timezone settings at the platform PHP application servers (Apache and NGINX) is performed within the [date] section of the main PHP configuration file - php.ini.

To access it, you need to click the Config button next to the required node. In the opened tab, locate the appropriate file within the file tree (or use the shortcut in the Favorites list to the left) and find the above-mentioned section:

Image 19: php.ini date settings As you can see, this section comprises two options, which can be used to:

Checking Timezone Data

The first setting allows you to use the alternative external timezone database (namely - the Olson one) in case the internal one is outdated.

Image 21: PHP update timezone rules For that, simply uncomment the appropriate extension through removing the first semicolon symbol, Save the made alteration and Restart your app server.

Now, if you click Open in browser and scroll until the date section of the opened phpinfo() page, you’ll see the latest timezone package version listed, with the denotation the external DB is used:

Image 22: PHP info date section

Changing Timezone PHP

The second option in the [date] section is intended for defining the current timezone location (by default it points to the UTC zone) of a node. For showing this on a real example, we’ll modify the default server’s start page (the /var/www/webroot/ROOT/index.php file) with the following code:

php

<?php
echo date("h:i:sa");
?>

Image 24: PHP check time app Now, if Saving the updated file and clicking Open in browser, you’ll see the timestamp output:

Image 25: PHP time UTC Return to the platform dashboard and specify the desired timezone as a value for the date.timezone parameter within the php.ini file (e.g., Australia/Sydney in our case).

Image 26: PHP change server timezone Again, Save your new configurations, Restart the corresponding PHP compute node and refresh the page with current time shown:

Image 27: PHP time Australia That’s it! As you can see, the timezone was successfully changed and now corresponds to a required location.