I have code that is moving date from a form into a new collection. All my lines work correctly except 1.
This line: “athlete1Birthdate”: new Date($w(“#dob1”).value),
is pasting this: “2015-05-30T04:00:00.000Z”
Instead of 05/30/2015
When I go into the collection it allows me to click on the field and convert it so I know I’m close.
I have also tried this:
“athlete1Birthdate”: $w(“#dob1”).value,
and get the same result.
The collection field is set to Date type
Any help would be greatly appreciated.
There are libraries to handle date formatting. For example: date-fns - modern JavaScript date utility library and you can install it with Wix’s NPM package installer: Working with npm Packages
If $w('#dob1')
is a calendar element then you should also be able to just store the date directly: “athlete1Birthdate”: $w(“#dob1”)
Kind of odd that the string “2015-05-30T04:00:00.000Z”
isn’t storing correctly since that should also be a valid ISO 8601 string.
This code crashes the let input. It needs the value added.
“athlete1Birthdate”: $w(“#dob1”)
Adding the .value does not work.
I have ended up converting the date to a text and copying it into a text field.
I would assume copying a date value would be able to be pasted into a date column/field, but it doesn’t work.