Skip to content

Instantly share code, notes, and snippets.

@riandoza
Created February 22, 2024 20:23
Show Gist options
  • Save riandoza/ecf547d19bac208e87f9129a1cecbb6f to your computer and use it in GitHub Desktop.
Save riandoza/ecf547d19bac208e87f9129a1cecbb6f to your computer and use it in GitHub Desktop.
Set Timezone for Web Development

Set Timezone in Ubuntu 22.04 LTS

Note: We use configuration for Indonesia Timezone UTC+7

Change timezone in OS (Ubuntu 22.04 LTS)

sudo timedatectl set-timezone Asia/Jakarta

Change timezone in database (Mariadb Server)

sudo tee -a /etc/mysql/my.cnf << EOF
[mysqld]
default-time-zone = "+07:00"
EOF

Then restart mariadb service

sudo service mariadb restart

Set timezone in PHP

<?php
date_default_timezone_set('Asia/Jakarta');
// ...
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment