-
Notifications
You must be signed in to change notification settings - Fork 571
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
text_datetime_timestamp_timezone field returns wrong datetime object #1465
Comments
Have you confirmed your WordPress timezone settings are matching what you're expecting for things? From /wp-admin/options-general.php ? |
Good work! |
I also wonder if the server's settings are playing a part in this, not just WP's timezone |
Even if it does, I don't think it should. I'll have to admit though, I always get confused with timezones.
When using the @tw2113 @mdibrahimk48 - are you able to reproduce this? If not, then obviously something is wrong with my environment. |
Ah, I just realized CMB2 also saves a UTC timestamp, so we can get the right results, see below:
|
I'd need to set up and confirm all parts in the local environment to confirm. However it sounds like you may have a way forward at the moment. |
Yes, using the saved UTC date does work. I'll dig into this a bit later and submit a PR. |
Throwing my experience into the mix. Testing on a dev server/site where the site TZ is set to America/Los Angeles. I don't think the server's TZ is factoring in. The date_utc value is correct but obviously has no TZ reference. Date: 12/2/2022 DateTime object: I believe that the "date" should be "2022-12-02 00:00:00.000000" The confusing bit is that the UI is correctly displaying the originally selected time. That is addressed by this line. I see a few possible areas to address this but not without disrupting existing users of the text_datetime_timestamp field. I haven't looked at the pull request yet. |
Yup, I realized the same thing - discarding the serialized object and using UTC only works, but that solution wouldn't follow CMB2 standards at all. @jtsternberg and I agreed on updating the docs to clarify the UTC value is the right one to use in #1468. |
Describe the bug
When using the
text_datetime_timestamp_timezone
field, setting a date, time and timezone, the savedDatetime object
returns the wrong date.Example:
Steps to reproduce:
Screenshots
CMB2 Field Registration Code:
Your Environment
Ubuntu, when running
date
in terminal results in: Tue Oct 18 15:11:45 UTC 2022Additional context
I read some other issues that mention this field, but don't think they are related to what I am experiencing here.
The text was updated successfully, but these errors were encountered: