Hi,
I have a strange issue and I can’t seem to figure out what is going wrong.
On my site (travel services), I have multiple datePickers where travellers input their birth date. After input, I store these datePicker input values in an array, along with all other birth dates of other travellers that are entered by the customer on the same page.
When I log the stored values from the array to the console, all is fine. But then, when I start to do some data manipulations to get certain string values I can later use on other pages, things go wrong.
After calling .getDate() on the stored date values in the array, the date I get returned and logged to the console is always 1 day behind compared to the original date that was entered in the datePicker.
See notes in code snippets for an example.
Frontend code snippet:
import { getBirthDate } from 'backend/getBirthDate.jsw';
var travellers_dateofbirth = { "traveller1_dateofbirth": undefined, "traveller2_dateofbirth": undefined, "traveller3_dateofbirth": undefined, "traveller4_dateofbirth": undefined, "traveller5_dateofbirth": undefined, "traveller6_dateofbirth": undefined, "traveller7_dateofbirth": undefined, "traveller8_dateofbirth": undefined, "traveller9_dateofbirth": undefined, "traveller10_dateofbirth": undefined };
// I will only use the case for traveller1 for this example snippet, but the issue happens with all travellers using the same code.
export async function button59_click(event) {
travellers_dateofbirth["traveller1_dateofbirth"] = $w("#datePicker6").value;
console.log(travellers_dateofbirth["traveller1_dateofbirth"]);
// e.g.: I input 13 January 1994, this logs "Thu Jan 13 1994 00:00:00 GMT+0100 (Midden-Europese standaardtijd)" to the console. This seems correct.
let birthDateData = await getBirthDate(1, travellers_dateofbirth, /* some other parameters not relevant here*/);
// Now I continue using these data but date is now wrong...
}
The backend function that I call:
export function getBirthDate(i, travellers_dateofbirth, /* some other parameters not relevant here*/) {
let traveller_dayofbirth = travellers_dateofbirth[`traveller${i}_dateofbirth`].getDate();
console.log(traveller_dayofbirth);
// In the same example as before (stored as "Thu Jan 13 1994 00:00:00 GMT+0100 (Midden-Europese standaardtijd)" in array), this logs "12" to the console. When I use this date later on my page it shows 12 January 1994.
// Now I continue using data but date is wrong... The rest of this backend code is not relevant here.
}
Can someone explain what is happening here? Thanks!