MySQL DATE_FORMAT '%M' 短月?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17900458/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MySQL DATE_FORMAT '%M' for short month?
提问by user2574794
I'm trying to display dates like this 27-Jul-13
. I keep reading that M
should give the shorthand month and F
the full name. I am using this:
我正在尝试显示这样的日期27-Jul-13
。我继续阅读M
应该给出速记月份和F
全名。我正在使用这个:
DATE_FORMAT(date, '%d-%M-%y') AS Displaydate
but it displays like this: 14-April-12
not 14-Apr-12
但它显示如下:14-April-12
不是14-Apr-12
Also if I use F
it doesn't work at all, it just displays an F
where the month should be. What am I doing wrong?
此外,如果我使用F
它根本不起作用,它只会显示F
月份应该在哪里。我究竟做错了什么?
回答by
According to DATE_FORMAT
doc, you need %b
for your format:
根据DATE_FORMAT
文档,你需要%b
你的格式:
DATE_FORMAT(date, '%d-%b-%y') AS Displaydate
回答by Erman Belegu
DATE_FORMAT(date, '%d-%b-%y') AS Displaydate