Dateformat doesn't work

Hi you all,

I am trying to convert a y/m/d format of a date to d/m/y format.
The date is passed by a page to a lightbox with itemData.
The lightbox gets the date, but doesn’t convert it to the options I would want it to display.

Does anyone have any idea why?
I tried to use “const” in stead of “let”, but no result neither.

function displayDate ( ) {
let receivedData = wixWindow . lightbox . getContext ()
let GotDate = receivedData . date
console . log ( GotDate ) //-> this receives the correct date, but y/m/d format
let options = { weekday : “long” , day : “numeric” , month : “short” , year : “numeric” } // That’s the format I would like it to display
let DisplayDate = GotDate . toLocaleDateString ( “nl-BE” , options )
console . log ( DisplayDate ) // → No result
}

If I remember correctly, that is a bug in JS. It only does US/UK formatting and ignores the params. Solution: use a date lib, like date-fns.npm, it has all the formatting options you need and it works.

No. There’s no such bug (in some old nodejs there was a bug like that, but it’s not relevant to new browser’s versions) .
But I don’t know why it didn’t work. It should work.

Thanks for refreshing my mind, JD.