drizzle-team / drizzle-team/drizzle-orm

[BUG]: Date retrieved from Mysql differs from date stored in Mysql

Open
#3,049 2 comments 0 reactions 0 assignees View on GitHub
bug db/mysql priority qb/crud
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### What version of `drizzle-orm` are you using?

0.33.0

### What version of `drizzle-kit` are you using?

0.24.2

### Describe the Bug

My timezone is Europe/Prague, I set it in both the database and in the drizzle connection however those hours differ, drizzle retrieves the dates and sets them + 2 hours

```
const connection = mysql.createPool({
uri,
timezone: 'Europe/Prague',
});
```

```
db:
container_name: my_db
image: mysql:latest
restart: unless-stopped
environment:
MYSQL_DATABASE: my_db
MYSQL_ROOT_PASSWORD: xxxxx
TZ: Europe/Prague
ports:
- "9106:3306"
volumes:
- ....
```

Example of dates retrieved from db:

STORED IN DB:
'10/4/2024, 8:08:56 PM',
'10/5/2024, 1:00:00 AM',
'10/4/2024, 6:11:12 PM',
'10/5/2024, 1:00:00 AM',
'10/4/2024, 5:54:18 PM'

DRIZZLE STATES:
'10/4/2024, 10:08:56 PM',
'10/5/2024, 3:00:00 AM',
'10/4/2024, 8:11:12 PM',
'10/5/2024, 3:00:00 AM',
'10/4/2024, 7:54:18 PM'

Please help me with this issue. Is drizzle converting the dates not using the timezone or is it using some time format which messes it up?

### Expected behavior

Expected behaviours is for the drizzle to retrieve same dates as are in the database.

STORED IN DB:
'10/4/2024, 8:08:56 PM',
'10/5/2024, 1:00:00 AM',
'10/4/2024, 6:11:12 PM',
'10/5/2024, 1:00:00 AM',
'10/4/2024, 5:54:18 PM'

DRIZZLE STATES:
'10/4/2024, 8:08:56 PM',
'10/5/2024, 1:00:00 AM',
'10/4/2024, 6:11:12 PM',
'10/5/2024, 1:00:00 AM',
'10/4/2024, 5:54:18 PM'

### Environment & setup

- MacOs: Sonoma 14.6.1
- Docker Mysql
- Nodejs v22.3.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.