am i doing something wrong here <cfscript> x...
# cfml-general
g
am i doing something wrong here <cfscript> x = '9/6/2024'; // its dd/mm/yyyy dump(dateformat(x,'yyyy-mm-dd')); </cfscript> month is getting wrong, its should be 6, its going in as 9
t
dateformat takes a date, not a string. So CF auto converts your string to a date, but does it using US rules which are mm/dd/yyyy. So you need an explicit call to parse your sting to a date:
DateFormat(ParseDateTime(x, 'dd/MM/yyyy'), 'yyyy-mm-dd')
👍 1
g
Thanks that explain it
s
Or use your locale and then LSDateFormat?