mysql query - format date on output?

后端 未结 4 1615
情书的邮戳
情书的邮戳 2021-01-16 06:57

In my table, dates are stored like this: 2011-03-03T13:30:00

I\'m trying to output dates like this: March 3, 2011 1:30 PM

I\'d much rather work it into the q

4条回答
  •  一向
    一向 (楼主)
    2021-01-16 07:14

    You should really use a DATETIME field for such things (and clean the input on the way in) rather than having to sort this out at the point of output.

    Irrespective, you can simply use the DATE_FORMAT function to re-format your field into the format you require, although this might produce some un-expected results on a VARCHAR or CHAR field. (If so, you'll have to use STR_TO_DATE or failing that some various string functions to extract the date bits you require.)

提交回复
热议问题