Keyword

Strange bug - created date changes on save

More
3 years 3 months ago #177680 by Jesse
This is a problem I've had with our site for a while, maybe even a year now.

The item edit form displays the created date incorrectly. Whatever gets saved in the database, several hours are subtracted from it. Since this incorrect date is loaded into the form, if I edit an item and save, this new incorrect value gets saved into the database.

I couldn't find anything on this googling around and searching through the forum. Has anyone heard of this happening before?

The only thing I can guess is maybe something to do with timezone of the server compared to timezone of the me? Exactly 5 hours are subtracted.

Please Log in or Create an account to join the conversation.

More
3 years 2 months ago #177741 by JoomlaWorks
Replied by JoomlaWorks on topic Strange bug - created date changes on save
There's a timezone offset setting in Joomla's Global Configuration. Have you checked that? Perhaps it's off by 5 hours...

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
3 years 2 months ago #177824 by Jesse
Replied by Jesse on topic Strange bug - created date changes on save
That did it, thank you Fotis!

It was set to UTC, and I had to set it to my local timezone, EST. It also explains another quirk, which is that the offset used to be by 4 hours, and then out of nowhere jumped to 5. It's because UTC doesn't change for daylight savings time!




The problem is fixed for me, but I do still think this is a bug. Is this the right place to make a bug report?

From my testing, when you create a new item, the default created date is based on your local timezone, not the globally configured timezone.

So for example, if it's 10am EST and I create an item, the stored date is 2021-01-06 10:00:00, but if my globally configured timezone is UTC it should be converted to 2021-01-06 15:00:00.

But it isn't. This means the stored date is incorrect.

When you go to edit an item, K2 assumes that the date is stored using the globally configured timezone, and converts that date to your local timezone. But since the stored date is wrong, the converted date is even more wrong. And every time you edit the item, even if you don't touch the date, it will save the new value to the database and compound the error.

Maybe it's not based on local timezone, maybe it's based on server timezone or something else, but either way, K2 is converting the date when the form is loaded, but not converting it back when the form is saved. Either they should both be converted, or neither should.

Please Log in or Create an account to join the conversation.

More
3 years 2 months ago #177832 by JoomlaWorks
Replied by JoomlaWorks on topic Strange bug - created date changes on save
K2 respects your configured timezone in Joomla's Global Configurations.

If it didn't, then your problem wouldn't have been solved by adjusting the timezone, would it?

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
3 years 2 months ago #177837 by Jesse
Replied by Jesse on topic Strange bug - created date changes on save
From what I can tell, K2 respects the configured timezone when retrieving.

I don't believe it respects it when saving though. No matter what I set my globally configured timezone to, if my form says "2021-01-06 10:00:00", and I save, that exact value is what is saved.

K2 assumes that the stored date matches the globally configured timezone. The reality is that the stored date matches my local timezone. To answer your question: by setting the globally configured timezone to match my local one, K2s assumption becomes correct, but for the wrong reasons. At least, as far as I can tell.

I'm not going to push it though, I just thought maybe I could be helpful. Thanks for your help pointing me to the setting in the global configuration, I appreciate it!

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum