Correct date and time settings are important for logs, scheduled tasks, and applications.
Prerequisites
- A VPS with OnetSolutions
- SSH access to your server
Setting the Timezone
Interactive Method
Command Line Method
Run the timezone configuration wizard:sudo dpkg-reconfigure tzdata
Follow the on-screen prompts to select your region and timezone. Set the timezone directly:sudo timedatectl set-timezone Europe/Paris
Replace Europe/Paris with your desired timezone.List all available timezones:timedatectl list-timezones
Common timezone values: Europe/Paris, Europe/London, America/New_York, Asia/Tokyo, UTC
Time Synchronization (NTP)
Debian/Ubuntu
Using systemd-timesyncd
Install and configure NTP:sudo apt update
sudo apt install ntp ntpdate -y
Sync time immediately:sudo ntpdate pool.ntp.org
Enable time synchronization:sudo timedatectl set-ntp true
PHP Timezone Configuration
To set the timezone for PHP applications:
Find the PHP config file
find /etc/ -name php.ini -type f
Edit the configuration
Open the php.ini file and add or modify:date.timezone = "Europe/Paris"
Restart web server
sudo systemctl restart apache2
# or
sudo systemctl restart php-fpm
Verify Settings
Check current date, time, and timezone: