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
问题描述
DATETIME
列,默认格式设置为' DD-MM -YYYY HH:MM:SS
' 我看到一个教程,它在 phpmyadmin
所以我怀疑我可以通过命令行使用mysql,并在使用
创建新表时实现同样的功能CREATE TABLE()
提前谢谢
MySQL以'YYYY-MM-DD HH:MM:SS'格式检索并显示DATETIME值。
这是从mysql网站。您只能存储此类型,但您可以使用许多时间格式函数中的一种来更改它,当您需要显示时。
例如,其中一个函数是 DATE_FORMAT ,可以这样使用:
SELECT DATE_FORMAT(column_name,'%m /%d /%Y%H:%i')FROM tablename
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
CREATE TABLE ()
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.
For example, one of those functions is the DATE_FORMAT, which can be used to like so:
SELECT DATE_FORMAT(column_name, '%m/%d/%Y %H:%i') FROM tablename
这篇关于Mysql:创建表时将DATETIME的格式设置为“DD-MM-YYYY HH:MM:SS”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!