Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong time on comments #2455

Closed
leemmoox opened this issue Apr 2, 2024 · 3 comments
Closed

Wrong time on comments #2455

leemmoox opened this issue Apr 2, 2024 · 3 comments

Comments

@leemmoox
Copy link

leemmoox commented Apr 2, 2024

What set up are you using

  • [ x ] Self Hosted via docker-compose.yaml

Describe the bug
All container has timezone UTC, for user setting the timezone is set to Europe/Berlin (+2 Hours). When adding new comment it set wrong time to +4 hours (instead of only +2 hours). After checking entry in MYSQL we saw time in DB ( +2 hours). Therefore I think it adding 2 hours twice -> once when update and another one when shows...

To Reproduce
Steps to reproduce the behavior:

  1. Select any exiting task in project( or create new one)
  2. Add comment

Expected behavior
Correct time on comments.

Leantime Version
Leantime 3.1.1

Server
NGINX

PHP / MySQL Version
myslq 8.0

Additional context
The leantime is build on docker-compose.yaml file from DOCu

@leemmoox
Copy link
Author

leemmoox commented Apr 3, 2024

Here you can see the screen (UTC time was 12:38:50 (set on db and app container), Europe/Berlin was +2 hour, but the comments show +4. In DB you can see it add +2 hours... and I think this is wrong as each user can have different timezone.

image
image
image

@sgissi
Copy link
Contributor

sgissi commented Apr 3, 2024

I just tested with 3.0.7 and the issue is there. Container time is set to UTC. I added a comment with the user set to Americas/Los_Angeles time, then changed to Americas/New_York and added another comment, see below. The entries date should read "2024-04-03 14:15:24" and "2024-04-03 14:17:55" but are offset by the timezone of the user.

I have no name!@leantime-mariadb-0:/$ date
Wed Apr  3 14:18:56 UTC 2024
[...]
MariaDB [leantime]> select * from zp_comment where id>6;
+----+--------+--------+---------------+---------------------+----------+-----------------------+--------+
| id | module | userId | commentParent | date                | moduleId | text                  | status |
+----+--------+--------+---------------+---------------------+----------+-----------------------+--------+
|  7 | ticket |      2 |             0 | 2024-04-03 07:15:24 |      189 | <p>test comment</p>   | 3      |
|  8 | ticket |      2 |             0 | 2024-04-03 10:17:55 |      189 | <p>test comment 2</p> | 3      |
+----+--------+--------+---------------+---------------------+----------+-----------------------+--------+

It is caused by date_default_timezone_set at https://github.com/Leantime/leantime/blob/master/app/Core/Middleware/Localization.php#L53, it will cause calls to date() to be offset by the timezone. A solution would be to use gmdate instead of date at https://github.com/Leantime/leantime/blob/master/app/Domain/Comments/Repositories/Comments.php#L206. The same problem exists for other repositories (e.g. Wiki).

@marcelfolaron
Copy link
Contributor

Fixed in 3.1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants