Are you my Client Script wizard?

Are you my Client Script wizard?

Hi Zoho Community! <3

I hope someone can help me with a JS-problem in a Client Script. I've been spending days on this, getting no where. I've tried ChatGPT, asked around in my network, nothing - so you guys are my last resort.

And the thing is: It should be suuuuuper simple, yet, it's not!

Here's the use case: I have 2 date fields. When i put in a date in "Date 1", i want "Date 2" to be filled with date 1's date + 1 day. So if I put in 01-09-2023 in "Date 1", it should write 02-09-2023 in "Date 2".

Simple right?

There are 3 big issues:
1) I use the date format DD-MM-YYYY, but it reads all my dates as MM-DD-YYYY
2) It currently outputs in a wierd ISO-format
3) Users have different date locale settings, so I need the output format to match the input format, so it works regardless of the users locale settings

Here's my - simple - code. It is set to execute onChange on the Date_1 field, which is the 'value':
  1. date2_field = ZDK.Page.getField('Date_2');

    const date1 = value;
    const date2 = new Date(date1);

    date2.setDate(date2.getDate() + 1);

    date2_field.setValue(date2);

And here is the output: