MagnusBilling
Operations

How to configure PHP and system timezone from the command line in MagnusBilling

Synchronize the Debian system timezone and the PHP timezone used by MagnusBilling, then verify both safely.

ENPTES

MagnusBilling reports, schedules and logs depend on consistent time. Configure the operating system and the PHP runtime that serves the panel with the same IANA timezone, then verify the application after the change.

Objective

Set one documented timezone for Linux and PHP so the panel, logs and scheduled tasks use a consistent clock.

Step-by-step instructions

1. Find the active PHP configuration

The CLI and Apache or PHP-FPM can load different php.ini files. Start with the CLI path and confirm the web SAPI path for your installation.

PHP_INI=$(php --ini | sed -n 's|Loaded Configuration File: ||p')
printf 'CLI php.ini: %s\n' "$PHP_INI"
php --ini
grep -n 'date.timezone' "$PHP_INI" || true

2. Choose a valid IANA timezone

Use timedatectl to search the installed timezone database. The example below uses America/Argentina/Cordoba; replace it with the required location.

timedatectl list-timezones | less
timezone='America/Argentina/Cordoba'
timedatectl status

3. Update date.timezone in php.ini

Back up the active file, replace an existing commented or active setting, and add the setting if it is absent.

cp -a "$PHP_INI" "$PHP_INI.before-timezone"

if grep -Eq '^[;[:space:]]*date.timezone[[:space:]]*=' "$PHP_INI"; then
  sed -i -E "s|^[;[:space:]]*date.timezone[[:space:]]*=.*|date.timezone = ${timezone}|" "$PHP_INI"
else
  printf '\ndate.timezone = %s\n' "$timezone" >> "$PHP_INI"
fi

4. Reload the web service

MagnusBilling on Debian normally uses Apache. If your deployment uses PHP-FPM, reload its exact service instead.

apache2ctl configtest
systemctl reload apache2

# Example only when PHP-FPM is used
# systemctl list-units 'php*-fpm.service'
# systemctl reload php8.2-fpm

5. Update the Linux system timezone

timedatectl updates /etc/localtime safely and records the selected zone.

timedatectl set-timezone "$timezone"
timedatectl status

6. Verify PHP and the operating system

Check the CLI value, system value and a MagnusBilling page or report. If the panel differs, identify the php.ini loaded by the web SAPI.

php -r 'echo date_default_timezone_get(), PHP_EOL; echo date(DATE_ATOM), PHP_EOL;'
date --iso-8601=seconds
grep -n 'date.timezone' "$PHP_INI"

Operational cautions

  • Run the commands as root or through sudo.
  • Record the previous timezone before changing it.
  • Use a maintenance window because cron jobs and reports can appear to move in time.
  • Do not leave a public phpinfo page on the server.
  • Changing the timezone does not rewrite historical timestamps already stored in the database.

Original article

Read the archived original article