0

I have a:

  1. Field in my store as date with dateFormat set to 'Y-m-d'
  2. Column in my grid (datecolumn) - format set to 'Y-m-d'
  3. Editor on Column (datefield editor) - format set to 'Y-m-d'
  4. Postgresql Table with a date column (Note, not a timestamp or timestamptz, but date)

I have data that comes into the store from Postgresql like: { mydatefield: "2021-07-30" }

Now, the date do dispay is 100% correct in the grid. Problem comes in when I select a new date, through the datefield editor, let's say

2021-07-31

The moment it saves back to the server it passes: mydatefield: '2021-07-30T22:00:00.000Z'

and the server saves it wrong as '2021-07-30' and the grid refreshes back to 2021-07-30.

We are on South African Standard Time (+2) Do not know if it something to do with Daylight Saving

So, to recap. It does not matter what date I select, it keeps saving a day less than the day I selected.

Schalk
  • 1

2 Answers2

0

The date it's saving is in UTC, which is the timezone you ought to be using on your server(s) and database(s) - that's a good thing as it removes timezone related info and allows dates to be localized to any timezone.

When you transmit date values over the wire between the server and the browser, make sure you're using RFC-8701 formatted strings (what you get when you call new Date().toJSON() in JavaScript). Then you won't have to worry about timezone issues, as RFC-8701 dates are always in UTC. The browser will take care of transforming dates to local time - just call new Date(myRfcDateString).

More info: Storing date/times as UTC in database

Roy Tinker
  • 10,044
  • 4
  • 41
  • 58
0

Use convert method of store to process data for date column before storing it in store data. Then the store data will be submitted to server in proper format.

There was similar question asked, links below -

Question - Datefield in grid editor

Fiddle - https://fiddle.sencha.com/#view/editor&fiddle/2e0a