Hi,
Finally I have reason to use K2 in a project. It's been many years that I've looked at it, and it's impressive how far and well it has grown.
Just for the record, I'm using K2 2.10.4 from Github with J! 3.9.28.
However, there's one huge issue with K2.
TL;DR: Why does K2 not store all*** dates/times in UTC in the database? That's the convention everywhere, all extensions (at least the ones I know) are doing it, and that's what makes sense and makes Joomla working properly with system global timezone versus user timezones (TZ).
Instead, K2 stores many or most dates/times, at least the ones visible = relevant for users, in the TZ as set in the user's account. Which makes no sense... none at all.
So, here's the long story:
I've seen many posts here, usually triggered by users wondering why a new or edited item ends up "pending". These are the users who are -- rightfully so -- having in their user accounts their timezone (TZ) set ahead of the system's global TZ. The "solution" they're being offered is for them to their individual user TZ to the same as Joomla's global one, means "default". This is not a solution, but results in defeating one of Joomla's great features: every user being able to set and see dates/times in their respective TZ as set in their account. The way K2 is handling it, that's just not possible.
K2 users, who have all user accounts set to the default system TZ or "behind/before" GMT (= GMT minus something), will probably never notice, indeed. But here am I (and obviously I'm not alone): I'll have users from all corners of the world logging in, and in both frontend and backend they should set and see dates/times in their respective TZ as per their Joomla user account, while guests in the frontend should see J!'s system time. Again, works everywhere, except for K2. And only because K2 stores critical dates/times in whatever the user's TZ is... instead of UTC.
Example:
J! global system TZ = UTC (so guests in the frontend see UTC/GMT).
My user TZ = GMT+8 (because that's where I happen to be).
I create a new K2 item. For "Creation date" and "Start publishing" I'm seeing my current date/time = say 2021-08-11 21:00:00 (while UTC and expected storage is 2021-08-11 13:00:00).
Unfortunately, and wrongly so, on save this exact "string" I am seeing is stored in the database. Not UTC.
As a result, what happens?
From other posts here, I sense that the same disaster happens for K2 comments and who knows what else as well...
So, do I have to hack "my" K2 to get it working as it should? Or can "we" = all K2 users get it so it stores all dates/times in UTC as per convention?
Thanks in advance for help from the K2 devs!
*** Actually, K2 stores some few dates/times correctly in UTC, e.g. the "modified" date/time of items. Why only those few? Makes even less sense, causes even more confusion.
EDIT:
Added to "Issues" in Github: github.com/getk2/k2/issues/540
Finally I have reason to use K2 in a project. It's been many years that I've looked at it, and it's impressive how far and well it has grown.
Just for the record, I'm using K2 2.10.4 from Github with J! 3.9.28.
However, there's one huge issue with K2.
TL;DR: Why does K2 not store all*** dates/times in UTC in the database? That's the convention everywhere, all extensions (at least the ones I know) are doing it, and that's what makes sense and makes Joomla working properly with system global timezone versus user timezones (TZ).
Instead, K2 stores many or most dates/times, at least the ones visible = relevant for users, in the TZ as set in the user's account. Which makes no sense... none at all.
So, here's the long story:
I've seen many posts here, usually triggered by users wondering why a new or edited item ends up "pending". These are the users who are -- rightfully so -- having in their user accounts their timezone (TZ) set ahead of the system's global TZ. The "solution" they're being offered is for them to their individual user TZ to the same as Joomla's global one, means "default". This is not a solution, but results in defeating one of Joomla's great features: every user being able to set and see dates/times in their respective TZ as set in their account. The way K2 is handling it, that's just not possible.
K2 users, who have all user accounts set to the default system TZ or "behind/before" GMT (= GMT minus something), will probably never notice, indeed. But here am I (and obviously I'm not alone): I'll have users from all corners of the world logging in, and in both frontend and backend they should set and see dates/times in their respective TZ as per their Joomla user account, while guests in the frontend should see J!'s system time. Again, works everywhere, except for K2. And only because K2 stores critical dates/times in whatever the user's TZ is... instead of UTC.
Example:
J! global system TZ = UTC (so guests in the frontend see UTC/GMT).
My user TZ = GMT+8 (because that's where I happen to be).
I create a new K2 item. For "Creation date" and "Start publishing" I'm seeing my current date/time = say 2021-08-11 21:00:00 (while UTC and expected storage is 2021-08-11 13:00:00).
Unfortunately, and wrongly so, on save this exact "string" I am seeing is stored in the database. Not UTC.
As a result, what happens?
- In the backend item listing:
- "Created" is 8hrs later: 2021-08-12 05:00:00.
- "Published" is promptly "pending".
- Frontend:
- First of all: nothing. Because it's "pending". For 8 more hours. Grrr.
- If it would be visible (or after at least 8hrs later)...
- ... a guest user sees "Created" still and wrongly in my TZ = as 2021-08-11 21:00:00 (instead of UTC = J! system TZ = 2021-08-11 13:00:00).
- ... a logged-in user with his TZ set to e.g. GMT-5 sees 2021-08-11 16:00:00 (instead of 2021-08-11 08:00:00).
- Now I need to edit the item. Oh. My. God. Because this is what happens -- on each and every save in edit mode:
- The "Creation date" and "Start publishing" times are pulled from the database, and 8 hours are being added! As if they are UTC in the database... but they aren't! If I hit "Save" 10 times, I get 80 hours added on both those times!!!!!!!!
- Means also that, after a few edits (or just clicking "Save"), the item is pending = vanished from the frontend for X hours.
From other posts here, I sense that the same disaster happens for K2 comments and who knows what else as well...
So, do I have to hack "my" K2 to get it working as it should? Or can "we" = all K2 users get it so it stores all dates/times in UTC as per convention?
Thanks in advance for help from the K2 devs!
*** Actually, K2 stores some few dates/times correctly in UTC, e.g. the "modified" date/time of items. Why only those few? Makes even less sense, causes even more confusion.
EDIT:
Added to "Issues" in Github: github.com/getk2/k2/issues/540
Edited 5 years 3 months ago by Thomas M