Namran Hussin Linux How to Set Linux Server Timezone to Malaysia (Asia/Kuala_Lumpur)

How to Set Linux Server Timezone to Malaysia (Asia/Kuala_Lumpur)

Let’s say, you have setup a new server which is running either Ubuntu 20.04 or Centos7.9

And while setting up cron, you notice the date time need to be offset correctly to have the actual time locally.

How about we just change the server to use local timezone altogether.

Here is how to do it.

If your Linux server is using UTC but your applications, cron jobs or logs need to follow Malaysia time, you can change the system timezone to:

Asia/Kuala_Lumpur

Malaysia Standard Time is UTC+8.

sudo timedatectl set-timezone Asia/Kuala_Lumpur

On most modern Linux distributions using systemd, changing the timezone takes only one command:

Then verify it with:

timedatectl

You should see something similar to:

Local time: Mon 2026-09-14 17:30:00 +08
Universal time: Mon 2026-09-14 09:30:00 UTC
Time zone: Asia/Kuala_Lumpur (+08, +0800)
System clock synchronized: yes
RTC in local TZ: no

This method works on most current Ubuntu, Debian, Rocky Linux, AlmaLinux, RHEL, CentOS and other systemd-based distributions.

 

Step 1: Check Your Current Server Timezone

Before making any changes, check the current server time:

timedatectl

You can also run:

date

A newly provisioned cloud server often uses UTC, for example:

Local time: Mon 2026-09-14 09:30:00 UTC
Universal time: Mon 2026-09-14 09:30:00 UTC
Time zone: Etc/UTC (UTC, +0000)

If the timezone shows Etc/UTC, your server is currently using UTC.

Step 2: Confirm the Malaysia Timezone

Linux uses IANA timezone identifiers.

To search for the Kuala Lumpur timezone:

timedatectl list-timezones | grep Kuala

The result should be:

Asia/Kuala_Lumpur

You can also check all Malaysian-related Asia timezone entries with:

timedatectl list-timezones | grep -E 'Kuala_Lumpur|Kuching'

For a server that should follow Kuala Lumpur / Peninsular Malaysia time, use:

Asia/Kuala_Lumpur

Step 3: Change the Linux Server Timezone to Malaysia

Run:

sudo timedatectl set-timezone Asia/Kuala_Lumpur

The command normally produces no output when successful.

Now check the configuration again:

timedatectl

You should see:

Time zone: Asia/Kuala_Lumpur (+08, +0800)

Also verify the current local time:

date

The displayed time should now correspond to Malaysia time.

Step 4: Verify /etc/localtime

On a typical modern Linux server, the system timezone is represented through /etc/localtime.

Check it with:

readlink -f /etc/localtime

You should get something similar to:

/usr/share/zoneinfo/Asia/Kuala_Lumpur

This is another way to confirm that the server is using the correct timezone.

Ubuntu and Debian

For modern Ubuntu and Debian systems using systemd, use:

sudo timedatectl set-timezone Asia/Kuala_Lumpur

Then:

timedatectl

Alternatively, Debian-based systems provide an interactive timezone configuration tool:

sudo dpkg-reconfigure tzdata

Select:

Asia

followed by:

Kuala Lumpur

For servers and automated deployments, I normally prefer timedatectl because it can be run directly without going through an interactive menu.

Rocky Linux, AlmaLinux, RHEL and CentOS

Modern Red Hat-compatible distributions also support timedatectl.

Use:

sudo timedatectl set-timezone Asia/Kuala_Lumpur

Check it:

timedatectl

There is usually no need to manually edit /etc/localtime when timedatectl is available.

If timedatectl Is Not Available

Older Linux distributions or minimal systems may not use systemd.

First check whether the timezone file exists:

ls -l /usr/share/zoneinfo/Asia/Kuala_Lumpur

If it exists, you can set /etc/localtime manually:

sudo ln -sf /usr/share/zoneinfo/Asia/Kuala_Lumpur /etc/localtime

Then check:

date

This fallback is mainly useful for older or stripped-down Linux installations.

Check Time Synchronization

Changing the timezone does not change the actual Unix system time. It changes how that time is presented locally.

Check synchronization with:

timedatectl

Look for something similar to:

System clock synchronized: yes

If your distribution supports systemd’s NTP control and synchronization is disabled, you can enable it with:

sudo timedatectl set-ntp true

Then check again:

timedatectl

The timezone and NTP synchronization are separate settings: the server can have accurate UTC time while still displaying it using Malaysia’s UTC+8 timezone.

What Happens to Cron Jobs?

This is one of the main reasons I originally changed the timezone on my server.

Suppose a cron job is scheduled to execute at:

0 2 * * * /path/to/script.sh

If the server uses UTC, 02:00 means 2 AM UTC, which is 10 AM Malaysia time.

After changing the system timezone to:

Asia/Kuala_Lumpur

a cron schedule based on the server’s local timezone will normally follow Malaysia time.

For important scheduled jobs, verify the next execution after making the change rather than assuming an existing application or scheduler has automatically picked it up.

You can inspect cron-related logs with commands appropriate to your distribution, for example:

journalctl -u cron

or:

journalctl -u crond

Check Web Server Log Timestamps

If your server runs Nginx or Apache, check whether log timestamps now reflect Malaysia time.

For Nginx:

sudo tail -f /var/log/nginx/access.log

For Apache on Ubuntu/Debian:

sudo tail -f /var/log/apache2/access.log

On some RHEL-family installations:

sudo tail -f /var/log/httpd/access_log

You should see timestamps using the +0800 offset where the log format includes a timezone.

There is generally no need to restart the entire web server merely because the operating-system timezone was changed. However, a long-running application can have its own timezone configuration or cache, so verify its output separately.

PHP Timezone Can Be Different From Linux

Changing the Linux timezone does not guarantee that PHP is configured the same way.

PHP has its own date.timezone setting. The PHP documentation identifies date.timezone as the default timezone used by its date/time functions.

Check PHP’s current timezone:

php -r 'echo date_default_timezone_get(), PHP_EOL;'

If necessary, set this in the relevant php.ini:

date.timezone = Asia/Kuala_Lumpur

Then reload or restart the PHP-FPM service that corresponds to the PHP version installed on your server.

You can verify again with:

php -r 'echo date("Y-m-d H:i:s T"), PHP_EOL;'

Asia/Kuala_Lumpur is a valid IANA-style timezone identifier, which PHP also supports through its timezone database.

Docker Containers May Still Show UTC

If the Linux host is using Malaysia time but a Docker container still displays UTC, remember that a container can maintain its own timezone environment.

Check inside a running container:

docker exec CONTAINER_NAME date

Some images support setting:

TZ=Asia/Kuala_Lumpur

For example in Docker Compose:

services:
  app:
    environment:
      TZ: Asia/Kuala_Lumpur

Whether this works directly depends on the container image and whether the necessary timezone data is installed.

Another common approach is to expose the host timezone configuration to the container:

services:
  app:
    volumes:
      - /etc/localtime:/etc/localtime:ro

Always check the application’s actual displayed time afterward.

Database Time May Be Different Too

MySQL and MariaDB applications can also use a database or session timezone that differs from the operating system.

Check:

SELECT NOW(), @@global.time_zone, @@session.time_zone;

If the values are SYSTEM, the database is configured around the system timezone behavior. Applications may nevertheless establish their own session timezone.

This is particularly important when troubleshooting a situation where:

  • Linux shows Malaysia time
  • PHP shows Malaysia time
  • but database timestamps still appear to be UTC

Check each layer rather than repeatedly changing the operating-system timezone.

Quick Troubleshooting

timedatectl: command not found

Your system may not use systemd.

Use:

sudo ln -sf /usr/share/zoneinfo/Asia/Kuala_Lumpur /etc/localtime

after confirming that the timezone file exists.

Server still shows UTC

Check:

timedatectl
date
readlink -f /etc/localtime

All three should be consistent.

PHP still shows UTC

Check:

php -r 'echo date_default_timezone_get(), PHP_EOL;'

and configure:

date.timezone = Asia/Kuala_Lumpur

if required.

Docker container still shows UTC

Check the timezone inside the container, not just on the host:

docker exec CONTAINER_NAME date

Then configure the container appropriately.

Cron runs at the wrong time

Confirm:

date
timedatectl

Then inspect the scheduler configuration and cron logs. Remember that applications such as WordPress, Java applications, containers and external schedulers can maintain timezone settings independently of Linux.

Summary

For most modern Linux servers, changing the server timezone to Malaysia requires only:

sudo timedatectl set-timezone Asia/Kuala_Lumpur

Then verify it:

timedatectl
date

The expected timezone is:

Asia/Kuala_Lumpur (+08, +0800)

This approach works across most current systemd-based Linux distributions, including Ubuntu, Debian, Rocky Linux, AlmaLinux, RHEL and modern CentOS installations.

Remember that Linux system time, PHP, Docker containers, databases and application-level timezone settings are separate layers. If an application’s timestamps remain incorrect after changing the Linux timezone, check its own configuration before changing the server again.

 

Examples logs

tail -f /var/log/apache/access.log

example:

52.77.255.203 - - [13/Mar/2022:20:36:44 +0800] "GET //i.php HTTP/1.1" 404 10072 "-" "python-requests/2.27.1"
 52.77.255.203 - - [13/Mar/2022:20:36:44 +0800] "GET //infos.php HTTP/1.1" 404 10080 "-" "python-requests/2.27.1"
 52.77.255.203 - - [13/Mar/2022:20:36:44 +0800] "GET //linusadmin-phpinfo.php HTTP/1.1" 404 10106 "-" "python-requests/2.27.1"
 52.77.255.203 - - [13/Mar/2022:20:36:44 +0800] "GET //dashboard/phpinfo.php HTTP/1.1" 404 10104 "-" "python-requests/2.27.1"


Done.

 

 

Originally published in March 2022. Updated in September 2026 with current Linux, PHP, Docker and troubleshooting guidance

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post