I want to convert "22.11.2022 00:00:00" to Mon Nov 21 2022 00:00:00 GMT+0300 (GMT+03:00) and set picker value.
My code:
view.picker.setValue(this.jsonData.dateData)
I tried
console.log(Ext.Date.format(dt, 'l, \\t\\he jS \\of F Y h:i:s A')); // Wednesday, the 10th of January 2007 03:05:01 PM
but it didn't work.
How can I do this?
The main problem here is that the datepicker expects a JavaScript Date as it's value. You could easily achieve that by creating a new JavaScript Date using new Date(this.jsonData.dateData)
. Since you are getting a german Date/String represenation this would still not work.
If you change to the correct formatting you should get a valid Date Object that you can set to the picker.
const dateString = "22.11.2022 00:00:00",
dateObject = new Date(dateString.replace(/(.*)\.(.*)\.(.*)/, '$2-$1-$3'));
picker.setValue(dateObject);
Here is a working example: sencha fiddle