Date formatting

Hi

I’m trying to format the date created into dd/mm/yyyy but the date is still displaying as mm/dd/yyyy.

The code I am using is

console.log ("original date = " + item._createdDate)
console.log ("formatted date = " + item._createdDate.toLocaleDateString(‘en-GB’))

The results are

original date = Fri Nov 15 2019 10:05:32 GMT+0000 (Coordinated Universal Time)
formatted date = 11/15/2019
original date = Wed Nov 13 2019 19:47:24 GMT+0000 (Coordinated Universal Time)
formatted date = 11/13/2019

I have checked region settings and they are UK with dd/mm/yyyy.

Could someone please help.

Maybe problem on your system. In my’s page use this code too and always is dd/mm/yy. if you want to set the dd/mm/yy for everybody, you can call getDate(),getMonth(),getFullYear() function.

I was trying to use the code in a data hook. Now I’m using toLocaleDateString() on the page and it works.

Thank you for your reply, I will use get functions on the data hooks.