Date field shows wrong date for some users

Hey,

I have a date field inside of a structure field and when I input data I see the correctly added date both in the panel and in the txt file. However when my client (based in US) looks at the same data (or adds data) the date shown in the datepicker is a day earlier than what is in the txt file. Does the user’s timezone or something else affect what is shown in the date fields?

Yes, I think so: Date-field doesn't save local time

However, if the date field displays something else than what is stored in the content file, then this is more than irritating and doesn’t make sense.

Yeah it does show something else than what’s stored for the client. For me it shows correctly though. Any ideas what could be happening there? Some server configuration thing?

I assume the JS library used for the date field converts data depending on timezone set on the server (php.ini). Maybe that even makes sense? Or is it a bug? I’m not sure.

Which js library does Kirby use?

day.js

@lauri What browser & os are your clients using? Different browsers and OS report dates differently. Some browsers use the system clock, some don’t. Day.js might be reacting to that i guess. I had a hell of a time once trying to get a date picker to show UK style dates in IE which was showing US style dates, but all the other browsers were correctly showing UK dates (or vice versa). As I recall, IE gets the date and time from the OS, other browsers don’t. Something like that.

Theres a console log command you can run in the browser dev tools that will tell you what date time format the browser is using, which in turn, is what javascript sees when it runs in the browser. I forget what it is but a bit of googling should tell you.

trouble is, I think it can only fixed in Kirby itself, to force the date formatting on the picker. I do recall their being a browser setting in IE that you can change how it reports dates. You could in the meantime get your US clients to investigate that.

The client is using Safari on macOS.

Intresting, but I suspect its the same deal, since Safari comes with the OS. It’s probably using the operating date, time and locale settings rather then the browser language & locale settings.

What happens if the use, say, firefox?

Sorry for the double posts.

Here my final opinion:

The date is saved in the webservers timezone in the content file e.g. 2019-04-02
When fetched from the panel the webservers timezone is used. Here in Switzerland with summertime that’s 2019-04-02T00:00:00+02:00
day.js transforms this value internally to GMT time: 2019-04-01 22:00 GMT
And all output is transformed to the users (browsers) timezone which makes it e.g. GMT-4 for New York City. Or 2019-04-01 18:00 local time in New York City. Therefore one day earlyer.

It would make sense to be able to define the timezone in the panel. There seems to be a plugin for day.js to handle timezones.

I’m having this problem and can’t seem to link it to the PHP timezone setting.

Example:

  • I choose 6-12 in the datepicker
  • It’ll show up as 6-11 when printed by the template
  • 6-11 is stored in the text data file
  • When I ask for today using php date I get the correct day

I’m confused about this because I assume it’s a javascript problem, but have no clue how to fix it. I updated kirby to no avail.

@acidhose What browser are you using? Do you get different results in a different browser?

Ah-ha! I fixed the timezone with my Apache settings and it worked.
Thanks.