# Time Zone UTC

Проблема: Дамп MySQL (MariaDB) видає час полів timestamp для TIME\_ZONE='+00:00'

Для прикладу, є така табличка:

```sql
CREATE TABLE `test` (
  `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
  `name` varchar(20) NOT NULL DEFAULT '',
  `dt` datetime NOT NULL DEFAULT '2000-01-01 10:00:00',
  `upd` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE
current_timestamp()
) ENGINE=MyISAM
```

Вносимо дані:

```sql
INSERT INTO test (name, dt) VALUES ('Peter',NOW());
INSERT INTO test (name, dt) VALUES ('Alex',NOW());
```

Перевіряємо:

```
select * from test;
| id | name  | dt                  | upd                 |
|  1 | Peter | 2023-04-14 11:36:42 | 2023-04-14 11:36:42 |
|  2 | Alex  | 2023-04-14 11:38:05 | 2023-04-14 11:38:05 |
```

Все ОК.

Робимо mysqldump, отримуємо:

```sql
-- MariaDB dump 10.19  Distrib 10.5.19-MariaDB, for debian-linux-gnu (x86_64)
...
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
...
INSERT INTO `test` VALUES
(1,'Peter','2023-04-14 11:36:42','2023-04-14 08:36:42'),
(2,'Alex','2023-04-14 11:38:05','2023-04-14 08:38:05');

...
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
...

```

Час в полі timestamp - на 3 години менший. Це створює певні проблеми в роботі...

Виправляємо:

```
sudo nano /etc/mysql/conf.d/time_zone.cnf
```

(створюємо файл, якщо нема) і додаємо в нього:

```
[mysqldump]
tz-utc=false
```

Перевіряємо, зробивши новий дамп - все ОК. З дампу пропали рядки про time\_zone\
`/* ... TIME_ZONE= ... */;`,  а час колонок timestamp - той самий, що і записаний в базі.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://olexsyn.gitbook.io/enote/data/mysql/mysqldump/time-zone-utc.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
