332 Posts
Kenneth
7 years ago
3
Topic

Hi,

I've had this issue every time I've tried to play with calendarfield and dates in Seblod. And I find no solution to it. Feeling a bit frustrated about it :P

I've created a app that is to list events. In these events we need a start date and time. For this I use the calendar field.

In this field I've set a date and time: 28.02.2017 14:00

When I edit the content, this same time and date is shown in the field.
When I check the database storage, the same date and time is shown as stored in the database.

But when I try to get this date echo'ed in a custom template, it shows the correct date but wrong hour. Now it shows me 04:00 instead of 14:00.

I've solved this before by using some code to add the hours needed for it to show correct. But that only works until you swtich to daylighs savings time etc. And then it's of by one hour unless i hardcode a change in the template. 

Why cant it just echo the correct hour as stored in the database? I can't understand why I always get this problem.

UPDATE:

The date is correct in content view, with custom templateing. But in list view it's not working as it should. There not only the time is off, but also the date when I look more into it. I'm using the list template when this error is prominent. When I combine list with another item template it is again correct.

Get a Book for SEBLOD
4229 Posts
Kadministrator
7 years ago
2
Level 1

Dates and hours are stored in UTC time, which is usually different than your local time. When you save and display date it is converted from local time to UTC and back. When you echo calendar field in custom template or override you should use text property, not value (value is in UTC, text should be converted). 

But a the above is currently not happening consistently, there is a pull request that should fix it https://github.com/Octopoos/SEBLOD/pull/199

332 Posts
Kenneth
7 years ago
1
Level 2

Okay. But in my content view, I use custom template and get value and it is correct. 

I use the same code in list template and it's not correct. But as I've been working on a solution here, I've found it to be correct if I combine list template with item template. 

4229 Posts
Kadministrator
7 years ago
0
Level 3

"in my content view, I use custom template and get value and it is correct." - you can currently, but unless you live in UTC timezone, this is a bug.

Get a Book for SEBLOD