I am trying to patch my form with the existing date object, but that date "object" is saved in Firebase as a string :
date: "2017-09-05T21:00:00.000Z"
I console.log date when I submit the form and see it appear as:
Thu Sep 28 2017 00:00:00 GMT+0300 (EEST)
So AFAIK I must convert it to that shape before patching the form. How do I do that? Especially "Thu Sep" confuses me. Also note, that I will use different languages in the Datepicker.
UPDATE:
Looks like I managed to make the Date object, but it's value is very wrong:
const str: string[] = this.initialValue.dateFrom.split('-');
console.log(str); // ["2017", "08", "31T21:00:00.000Z"] - correct date
const day = str[2][0] + str[2][1];
console.log(day); // 31 - correct
this.initialValue.dateFrom = new Date(+day, +str[1], +str[0]);
console.log(this.initialValue.dateFrom); // Tue Mar 09 1937 00:00:00 GMT+0200 (EET) - not correct.
new Date(this.initialValue.dateFrom).toISOString()Thu Sep 28 2017 00:00:00 GMT+0300 (EEST)