Skip to content

Fix: SQL queries using NOW() rely on MySQL timezone instead of shop timezone#177

Closed
mattgoud wants to merge 1 commit into
PrestaShop:devfrom
mattgoud:fix-30828-replace-sql-now-with-php-date
Closed

Fix: SQL queries using NOW() rely on MySQL timezone instead of shop timezone#177
mattgoud wants to merge 1 commit into
PrestaShop:devfrom
mattgoud:fix-30828-replace-sql-now-with-php-date

Conversation

@mattgoud

@mattgoud mattgoud commented Jun 2, 2026

Copy link
Copy Markdown
Contributor
Questions Answers
Branch? dev
Description? Several SQL queries used `NOW()` which relies on the MySQL server timezone (UTC by default), instead of the shop's configured timezone (PHP). This could cause incorrect behavior when the shop timezone differs from the MySQL server timezone.

Changes:
- `GanalyticsRepository::findAllByShopIdAndDateAdd()`: `DATE_ADD(date_add, ...) < NOW()` replaced with a PHP-computed datetime string
- `GanalyticsRepository::addOrder()` and `markOrderAsSent()`: `NOW()` SQL value replaced with `date('Y-m-d H:i:s')`
- `HookDisplayBackOfficeHeader`: `BETWEEN NOW() - INTERVAL x DAY AND NOW() - INTERVAL 30 MINUTE` replaced with PHP-computed interval boundaries
Type? bug fix
BC breaks? no
Deprecations? no
Fixed issue or discussion? Related to PrestaShop/PrestaShop#30828
Related PRs PrestaShop/PrestaShop#41596
Sponsor company PrestaShop SA

Replace NOW() in raw SQL queries with PHP's date() so that the shop's
configured timezone is always used instead of the MySQL server timezone (UTC).

Fixes PrestaShop/PrestaShop#30828

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ps-jarvis

Copy link
Copy Markdown

Hello @mattgoud!

This is your first pull request on ps_googleanalytics repository of the PrestaShop project.

Thank you, and welcome to this Open Source community!

@mattgoud

mattgoud commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

Closed. Alternative solution proposed by the PR PrestaShop/PrestaShop#41628

@mattgoud mattgoud closed this Jun 5, 2026
@github-project-automation github-project-automation Bot moved this from Ready for review to Closed in PR Dashboard Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

2 participants