pimcore / pimcore

Core Framework for the Open Source Data & Experience Management Platform (PIM, MDM, CDP, DAM, DXP/CMS & Digital Commerce)
http://www.pimcore.com
Other
3.41k stars 1.44k forks source link

[Bug]: Problem with TimeZone #16184

Closed Krapfeen closed 4 months ago

Krapfeen commented 1 year ago

Pimcore version

10.6.9

Steps to reproduce

Playback Environment: \ Windows 10 Chrome Browser Version 118.0.5993.71 (Official Build), (64 bit) Timezone: GMT+5

Precondition: \ Pimcore 10.6.9 Timezone Server GMT+3 \config\config.yaml:

pimcore: general: timezone: Europe/Moscow "pimcore/data-hub": "^1.6" v. 1.6.3

Holydays class with the Date field type

Playback Steps: \

  1. Go to a DataObject
  2. Create an object of the holydays class
  3. In the Date field, specify the date, for example 20.10.2023
  4. Save and publish
  5. Go to the Versions tab and pay attention to the Date field (2023-10-19)
  6. Execute the request:
{
  getHolidays(id: $id) {
    date
  }
}

Comment: When saving the value in the Date field, the client's time zone is taken into account, not the server's, respectively, the UTC label is saved for 5 hours less. At the same time, if the server with Pimcore is located in a time zone that differs from the Pimcore user's time zone, then the API will be given a value that corresponds to the server's time zone, relative to the stored timestamp

Actual Behavior

{
  "data": {
    "getHolidays": {
      "date": "2023-10-19 22:00:00"
    }
  }
}

Expected Behavior

{
  "data": {
    "getHolidays": {
      "date": "2023-10-20 00:00:00"
    }
  }
}
kingjia90 commented 1 year ago

Confirming, i've noticed something similar few days ago https://github.com/pimcore/object-merger/pull/42#issuecomment-1785074317

github-actions[bot] commented 11 months ago

Thanks a lot for reporting the issue. We did not consider the issue as "Priority" or "Backlog", so we're not going to work on that anytime soon. Please create a pull request to fix the issue if this is a bug report. We'll then review it as quickly as possible. If you're interested in contributing a feature, please contact us first here before creating a pull request. We'll then decide whether we'd accept it or not. Thanks for your understanding.

markus-moser commented 5 months ago

The problem consists of multiple parts. The main problem is that there are different use cases for date values:

  1. When used as point in time (e.g. the timestamp when a online shop order was created): The date values should be formatted with respect of the user's timezone.
  2. When used as time indication (e.g. the date/time when a event starts in a specific locality): The dates should be formatted independent of the user's timezone.

Currently Pimcore only supports the 1. option for date/datetime fields within data objects or asset metadata. Additionally this implementation has some bugs:

In addition to that Pimcore should offer a option to switch between the 2 modes on datetime attribute level depending on the use case.

=> Fixed in https://github.com/pimcore/pimcore/pull/17151 and https://github.com/pimcore/admin-ui-classic-bundle/pull/560. With enabled timezone support would be the "point in time" mode whereas without timezone support is the "time indication" mode.

For the datahub case mentioned in the issue description the easiest solution for now could be to set the Pimcore server timezone if you are not in an environment where different timezones matter:

pimcore:
    general:
        timezone: Europe/Berlin

In the future this needs to respect also the 2 different modes/use cases.

kingjia90 commented 4 months ago

Fixed by https://github.com/pimcore/pimcore/pull/17117 and all the related PRs