I do not want code to send the date converted to MySQL, I want to know if it is possible for the date to appear as 09/05/2018 09:59:54
instead of 2018-05-09 09:59:54
.
Is it possible to change this in some configuration?
I do not want code to send the date converted to MySQL, I want to know if it is possible for the date to appear as 09/05/2018 09:59:54
instead of 2018-05-09 09:59:54
.
Is it possible to change this in some configuration?
First of all, I agree with @Wallace that the ideal is to handle the application, but as you asked, the answer would be:
Documentation is your friend:
The language of the date is controlled by the variable lc_time_names
, but THIS DOES NOT CHANGE THE ISO FORMAT , only the language!
Example taken from the manual:
mysql> SELECT DATE_FORMAT('2010-01-01','%W %a %M %b');
+-----------------------------------------+
| DATE_FORMAT('2010-01-01','%W %a %M %b') |
+-----------------------------------------+
| Friday Fri January Jan |
+-----------------------------------------+
1 row in set (0.00 sec)
mysql> SET lc_time_names = 'es_MX';
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT @@lc_time_names;
+-----------------+
| @@lc_time_names |
+-----------------+
| es_MX |
+-----------------+
1 row in set (0.00 sec)
mysql> SELECT DAYNAME('2010-01-01'), MONTHNAME('2010-01-01');
+-----------------------+-------------------------+
| DAYNAME('2010-01-01') | MONTHNAME('2010-01-01') |
+-----------------------+-------------------------+
| viernes | enero |
+-----------------------+-------------------------+
1 row in set (0.00 sec)
If it's PHP, you can use the bank date and display it in the desired format:
$date = new DateTime($data_do_banco);
echo $date->format('d/m/Y H:i:s');
But you can also do this by selecting:
SELECT id, nome, DATE_FORMAT(data, "%d/%m/%Y H%/%i/%S") as data_formatada FROM table