When I retrieve a date from my collection , the date is correct. After changing the format in code, the date is formatted properly, but the date has changed to 1 day prior.
My Code Example:
const date = $w(“#dynamicDatasetMain”).getCurrentItem().dob;
console.log(date) // Outputs “1956-12-18” (Correct date)
const options = {
day: ‘numeric’,
month: ‘long’,
year: ‘numeric’
};
const longDOB = new Date(date).toLocaleDateString("en-US",options);
console.log(longDOB); // Outputs “December 17, 1956” (Correct format, wrong date.)
------------- end -------------
Using .toDateString( ) instead yields “Mon Dec 17, 1956”. The expected format, but again the date is displayed as the prior day.
Any ideas to solve this?
Product:
[Which editor or feature is your question most relevant to? Wix Editor