const d = new Date() const currentdate = d.toLocaleDateString() export function button2_click(event) { let toInsert = { "title": '', "detail": $w('#textBox1').value, "date": currentdate }; wixData.insert("visits", toInsert) .then((results) => { let item = results; //see item below }) .catch((err) => { let errorMsg = err; }); $w('#textBox1').value = '' }
i have a stupid problem i can't fix it
all what this code do store the damn local date
but when i check how the stored date looks like i finde this
i wnat it to be like this : 24 / 2 / 2022
please help i am stressed out for 2 ours
@AmandaM&@Kristof
constcurrentdate=d.toLocaleDateString('en-US')
this line solve it thanks for both of you guys
but when amanda said try the published version , there it is another problem.
the code now is running smoothly , but only in preview mode and dose not work in the published site
(what i meant by dose not work that when i go to the collection there is no data have been inserted)
can any one tell why ?
I just tested on my site with your code and the string was inserted as expected so this is curious. I noticed that in your screenshot it says that this site has not been published yet. Are you able to publish and test not in preview just to rule out a preview mode oddity?
also I am moving this post to coding with velo, it be more appropriate in that category
Hello. What field type are you using in the collection? If it is a date field, then my guess is that toLocaleString is what is messing you up because when you use that, the date is no longer a date object but a string.