Re: MySQL and DATE display problem
| From: | John McKown | Date: | Mon, 02 Oct 2000 02:24:49 +0000 |
| Subject: | Re: MySQL and DATE display problem | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-3202@lists.php.net to get a copy of this message | ||
On Sun, 1 Oct 2000, Vikesh wrote:
> I'm sure this is a simple query.. but I'm new to PHP
> and MySQL:
>
> I have a db where one field holds the date. As you
> all probably know the date is stored in the following
> way:
>
> YYYY/MM/DD
>
> when I query the db from an html form and PHP, the
> result also gets posted in this way (ie YYYY/MM/DD)
>
> How do I get the date to display in the following
> format:
>
> DD/MM/YYYY?
>
Well, the simpliest way is probably the best. Suppose the date is in
the variable $date. Then do:
euro_date=substr($date,9,2).'/'.substr($date,6,2).'/'substr($date,1,4);
Or change your MySQL query similiar to:
SELECT DATE_FORMAT(datefield,'%d/%m/%Y') as euro_date ...
I'm not real MySQL literate, but the above should be close.
John