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

Date Field Time Not Saving Correctly For SuperAdmins in Different Locations #114

Closed
capstonedesign opened this Issue Jan 30, 2019 · 5 comments

Comments

Projects
None yet
2 participants
@capstonedesign
Copy link

capstonedesign commented Jan 30, 2019

Description of the problem

I have a Grid field with one of the columns being a Date Fieldtype Field. On the publish page that uses this Grid/Date field, the date field displays different times for me as a SuperAdmin publisher than another editor, also a SuperAdmin, who is in my current time zone, but in a different state.

For example, when I enter a date and time in the field, it saves it correctly for me. So if I choose February 3, 2019 and update the time to 9:00 AM it saves correctly for me as 2/3/2019 9:00 AM. However, for some reason, when my client views it and is updating the TIME, it changes the time to 5 hours earlier when she saves the page.

Let me try to explain that again in case it isn't clear. Let's say the other publisher (in another state) updates that date field TIME from 2/3/2019 9:00 AM to 2/3/2019 10:00 AM, when I try to edit it (logged in as another SuperAdmin user), I see 2/3/2019 5:00 AM. It's like the hours are changing to 5 hours earlier when the other SuperAdmin updates the TIME in the Date Fieldtype. She also sees this new time, when either one of us makes a TIME change.

We would like whatever date and time we enter stays and NEVER changes. So, if I enter 2/3/2019 9:00 AM, it NEVER changes.

Currently the settings for that Date Field have Localize Date turned off. I did try to test the problem by turning in Localize Date on (but it didn't work).

How To Reproduce
Steps to reproduce the behavior:

  1. Create a Date Fieldtype field within a Grid Field (you may want to try outside of Grid field as well)
  2. Edit an entry in a Channel using that field and save a date and time IE 2/3/2019 9:00 AM and save the entry.
  3. Ask someone else to login in using their own credentials (preferably in a different location) and ask them to update that entry to a different time (keeping the same date)- IE 2/3/2019 11:00 AM - and save the entry.
  4. Then try to view that entry again using your credentials and see if the time has changed for you.

Screenshots / Videos / Template Code
You can view a screencast explaining my issue at https://www.screencast.com/t/xJ64yVnAX

Environment Details:

  • Version: 5.1.2
  • PHP Version 7.0.32
  • MySQL Version 5.0.12
  • OS: macOS, Windows
  • Web Server: Apache (cPanel WHM)

Possible Solution

Additional context

@kevincupp

This comment has been minimized.

Copy link
Contributor

kevincupp commented Jan 31, 2019

Sorry for the trouble, I think I can see how this might be happening. Can you try applying the below patch? And if you want the time to stay the same across timezones, then make sure you have "Localize date?" turned off.

--- a/system/ee/legacy/libraries/Session.php
+++ b/system/ee/legacy/libraries/Session.php
@@ -567,6 +567,11 @@ class EE_Session {
                // Turn the query rows into array values
                foreach ($member_query->row_array() as $key => $val)
                {
+                       if (in_array($key, ['timezone', 'date_format', 'time_format', 'include_seconds']) && $val === '')
+                       {
+                               $val = NULL;
+                       }
+
                        if ($key != 'crypt_key')
                        {
                                $this->userdata[$key] = $val;
@capstonedesign

This comment has been minimized.

Copy link
Author

capstonedesign commented Jan 31, 2019

@kevincupp How do I apply this patch? Do I go to Session.php and add those 5 lines of code with the + (plus) symbol before them? Is this file in system/ee/legacy/libraries/Session.php?

@kevincupp

This comment has been minimized.

Copy link
Contributor

kevincupp commented Jan 31, 2019

Yep! Just without the + symbol. Should be placed around line 567, use the context above for where to place it exactly.

@capstonedesign

This comment has been minimized.

Copy link
Author

capstonedesign commented Jan 31, 2019

Thank you! Will this be updated in future EE updates? I haven't tested it yet to confirm it worked.

@kevincupp

This comment has been minimized.

Copy link
Contributor

kevincupp commented Jan 31, 2019

Yes if it clears things up for you, I’ll commit it for the next EE release.

@kevincupp kevincupp closed this in 0dd0069 Feb 12, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.