> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# How to Solve the Time Synchronization Problem on Vicidial

When the timezone is set differently on the server, in the Vicidial database and in PHP, you will receive the following error:

```
There is a time synchronization problem with your system, please tell your system administrator
```

To resolve this, set the same timezone for the server, the Vicidial database and PHP.

:::warning

Make changes to the timezone settings if needed, and make sure the server and PHP are configured with the same timezone.

:::

## Fix the Time Synchronization Problem


### Check the server timezone
```bash
timedatectl
```
Output:
```
vicibox9:~ # timedatectl
      Local time: Tue 2021-06-08 14:02:11 UTC
  Universal time: Tue 2021-06-08 14:02:11 UTC
        RTC time: Tue 2021-06-08 14:02:11
       Time zone: UTC (UTC, +0000)
```
### Check the PHP timezone
Check the `date.timezone` setting in `/etc/php7/apache2/php.ini`:
```bash
cat /etc/php7/apache2/php.ini | grep timezone
```
Output:
```
vicibox9:~ # cat /etc/php7/apache2/php.ini | grep timezone
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone =
vicibox9:~ #
```
### Compare the server, PHP and database times
If the issue persists after you have made the changes above, run the following command. It compares the time values in the server, PHP and the Vicidial database:
```bash
echo "SELECT server_ip, UNIX_TIMESTAMP(last_update),UNIX_TIMESTAMP(db_time) from server_updater" | mysql -uroot asterisk && php -r "date_default_timezone_set('America/New_York'); echo 'php time: '.date('U');" && echo ""
```
Output:
```
vicibox9:~ # echo "SELECT server_ip, UNIX_TIMESTAMP(last_update),UNIX_TIMESTAMP(db_time) from server_updater" | mysql -uroot asterisk && php -r "date_default_timezone_set('America/New_York'); echo 'php time: '.date('U');" && echo ""
server_ip       UNIX_TIMESTAMP(last_update)     UNIX_TIMESTAMP(db_time)
193.29.57.151   1623161611      1623161611
php time: 1623161612
```
### Run the update script
To resolve the issue, run the following script:
```bash
/usr/share/astguiclient/AST_update.pl
```
Output:
```
vicibox9:~ # /usr/share/astguiclient/AST_update.pl
SHOW CHANNELS format: 1
LOOKING FOR Zap/DAHDI clients assigned to this server:
LOOKING FOR IAX2 clients assigned to this server:
LOOKING FOR SIP clients assigned to this server:
gs102
Zap Clients:  |
IAX2 Clients: |
SIP Clients:  |gs102|gs102@gs102|
pattern match timed-out at /usr/share/astguiclient/AST_update.pl line 470
```
The `pattern match timed-out at /usr/share/astguiclient/AST_update.pl line 470` error occurs when the response from the **Asterisk server** does not match the regex pattern. If you see it, continue with the next step. If the script finishes without that error, skip to the last step.
### Fix the pattern match timeout (only if you see the error)
Open `/usr/share/astguiclient/AST_update.pl` and find this line:
```
$t->waitfor('/[0123]\n$/');
```
Replace it with:
```
$t->waitfor('/[0123456789]\n$/');
```
or:
```
$t->waitfor('/Asterisk Call Manager.+\n$/');
```
### Re-run the script and verify
After making the change, run `/usr/share/astguiclient/AST_update.pl` again. Then confirm the fix by running the comparison command once more:
```bash
echo "SELECT server_ip, UNIX_TIMESTAMP(last_update),UNIX_TIMESTAMP(db_time) from server_updater" | mysql -uroot asterisk && php -r "date_default_timezone_set('America/New_York'); echo 'php time: '.date('U');" && echo ""
```
Output:
```
vicibox9:~ # echo "SELECT server_ip, UNIX_TIMESTAMP(last_update),UNIX_TIMESTAMP(db_time) from server_updater" | mysql -uroot asterisk && php -r "date_default_timezone_set('America/New_York'); echo 'php time: '.date('U');" && echo ""
server_ip       UNIX_TIMESTAMP(last_update)     UNIX_TIMESTAMP(db_time)
193.29.57.151   1623164839      1623164839
php time: 1623164839
```
