At 14:02 +0000 2/28/02, George Pitcher wrote:
>I asked this question on the PHP-DB list but everyone was asleep (no
>===== ===== ===== ===== ===== ===== =====
>I have a site where dates are being displayed and also entered by users. I
>don't want to offend them by asking them to use the yyyy-mm-dd format or to
>split the date into its constituent parts.
>I am displaying by using the MySQL Date_Format syntax and that's fine. I get
>dd/mm/yyyy and I want to be able to have the user enter 'dd/mm'yyyy' into a
>form and have it put into MySQL in the yyyy-mm-dd format.
>Now I have written a function in php to do this but I might be missing an
>easier, more elegant/efficient way of doing this.
I'd leave the checking in PHP. You have access to pattern matching and
reformatting capabilities that are as easy or easier to use than what
you can do with SQL, plus if you issue a query to reformat the
date and it turns out to be bad, you ran the query for nothing.
>George P, in Edinburgh