[GH #3730] Formatting date

How to change date format? I tried to do this in handsontable example (http://jsfiddle.net/vg6d58fn/) but even in this example doesn’t work. For example I try change MM/DD/YYYY to YYYY.MM/DD

here you go: http://jsfiddle.net/yc2gjfcb/
I’ve updated the example to 1.6.0 (yours was 0.15.0-beta1)

MM/DD/YYYY to YYYY.MM/DD The dot in this expression was obviously a mistake – I mean MM/DD/YYYY to YYYY/MM/DD. This example also does not work.

Hi @pranosz
I guess that maybe I’ve misunderstood the request as when I’m checking the behavior it’s working as it should.

Generally there are two parts of code that we need to discuss: set value (blue background, set via dateFormat: 'YYYY/MM/DD') and provided via data option (green, from the getCarData()) (source: Handsontable example - JSFiddle - Code Playground)

If your data contains a cell let say like 10.10.2010 (DD/MM/YYY) the value won’t change to 2010/10/10 (with a dateFormat: 'YYYY/DD/MM') without editing the content.

This functionality does’t make sense :slight_smile: It is possible to set date format in cell without editing cell?

You can call the instance.validateCells() to do the job but it’s not always transforming the data as expected.

Here’s an example: http://jsfiddle.net/fmj8Lkoj/

case:
The format is: YYYY/MM/DD

result:
2010.10.25 changed to 2010/10/25 (as intended), but
20/10/2011 changed to 20/10/2011 and is marked as invalid (there’s no 20th month) and
10/02/2011 became 2011/10/02

That’s why the automatic conversion (via validator) may or may not be a good idea - it depends of the input.

This issue is related with https://github.com/handsontable/handsontable/issues/3730.