Hello everyone,
Clients fill up a custom Members Sign Up form on my website, which among other things captures a date. They input the date with a Date Picker.
Once the client completes the sign up, I receive an automated email with the relevant info.
On another page I past their email address on a form and I then use this code to pull the sign up information into the form.
export function inputLoginEmail1_change(event) { let client1 = $w('#inputLoginEmail1').value; partnerEmail = client1; wixData.query("Members/PrivateMembersData") .eq('loginEmail', client1) .find() .then((results)=>{ if (results.items.length === 0) { $w('#textUserError').show(); } else { $w('#textUserError').hide(); let items=results.items; let FN = items[0].firstName; let LN = items[0].lastName; let userID = items[0]._id; customFieldsFunction(userID) .then((customFields) => { console.log(customFields) let options = { day: 'numeric', month: 'long', year: 'numeric' }; let DoB = customFields.DoB; let CoB = customFields.Birthplace; let Referral = customFields.Referral; let Gender = customFields.Gender; let Phone = customFields.phones.toString(); let CoR = customFields.Residence; $w('#inputDoB').value = DoB; $w('#inputCoB').value = CoB; $w('#inputCoResidence').value = CoR; $w('#inputGender').value = Gender; $w('#inputReferred').value = Referral; $w('#inputPhone').value = Phone; }) $w('#inputFN').value = FN; $w('#inputLN').value = LN; } }) }
Here is the part that I need help with.
When I receive their confirmation email, the date they entered in the form appears correct, however, when the above code pulls the date from the collection it always appears one day earlier; so if the client input 27 Oct 1989, this is the date that will appear on the email, but the above code would show this instead 1989-10-27T16:00:00Z
Is the above code the reason for this issue?
Thank you
I followed this post to format dates and I placed the toLocaleDateString()
first here:
let DoB = customFields.DoB.toLocaleDateString();
then here:
$w('#inputDoB').value = DoB.toLocaleDateString();
Given than the info is being pulled into an input field as .value, I also tested pulling the date to a text line as .text, but I still get the same error message ("toLocaleDateString is not a function") in the Console log.
Any suggestions please?
Got it. Thank you for the suggestion, I will try.
No, it is correct. The JS system store dates in UTC +0. You need to format the date into your timezone and readable format.