Mysql:创建表时将DATETIME的格式设置为'DD-MM-YYYY HH:MM:SS' [英] Mysql: Setup the format of DATETIME to 'DD-MM-YYYY HH:MM:SS' when creating a table



After googling around, I cannot find a way to create a new table with a DATETIME column with the default format set to 'DD-MM-YYYY HH:MM:SS'

I saw a tutorial in which it was done in phpmyadmin so I suspect that I could use mysql via command line and achieve the same thing when creating my new table with


Thank you in advance


"MySQL retrieves and displays DATETIME values in 'YYYY-MM-DD HH:MM:SS' format." This is from mysql site. You can store only this type, but you can use one of the many time format functions to change it, when you need to display it.

Mysql Time and Date functions

For example, one of those functions is the DATE_FORMAT, which can be used like so:

SELECT DATE_FORMAT(column_name, '%m/%d/%Y %H:%i') FROM tablename

登录 关闭
发送“验证码”获取 | 15天全站免登陆