What may be happening is that by default, dateformat() interprets a date
that could be MM/DD or DD/MM in the American way, MM/DD. What I don’t know
is if Lucee will correctly interpret the date if you use LSDateFormat.
I’ve run into this on ACF, and use the date widget from jQuery to work
around it, basically to ensure a date is always submitted in the
unambiguous YYYY-MM-DD format, and displayed to the user consistently and
correctly in the DD-MM-YYYY format. I’d do the same on Lucee, even if I
found a correct pathway through this morass, simply to ensure that dates
are always represented in a consistent way, especially for functions like
DateAdd(), for example.
Aria Media Sagl
Via Rompada 40
6987 Caslano
Switzerland
DateFormat ignore your locale settings completely, this function only using
the US date locale, let me explain what is exactly going on in your
examples.
dateformat(“01/07/2015”, “MM-DD-YYYY”)
the date string with the first argument is parsed to a date object using us
“locale” rules (month/day/year) what means inside the function we have the
a date object for the 7th of january 2015.
This date then is converted to a string using the pattern you have defined.
So the outcome is as expected and “correct”.
I completely agree that this behaviour is weird if you not using an us
locale for your environment.
There is one simple reason for this, the date functions are pure us locale
based and ignore every other locale set, simply because locale and the “LS”
function was introduced later (in Macromedia CF?), so for backward
compatibility they work still the classic way.
we should even consider to deprecate them for Lucee 5!
BTW in the Lucee dialect from Lucee 5 we have removed ALL this date/time
function and removed the “LS” from the “LS” function, so in the
Lucee dialect your code will work as expected!
MichaOn Thu, May 7, 2015 at 11:09 AM, Gavin Baumanis <@Gavin_Baumanis> wrote:
Hi Everyone,
I am having a WTF moment…
I have a form where the date is entered in AUSTRALIAN format DD/MM/YYYY
On the form it is submitted to I have the following code;
form: #form.startdate#