how to change timestamp format in mysql

前端 未结 5 1708
不知归路
不知归路 2021-01-26 02:37

Is it possible to change the current 24 hr format like 22:16:08 to something like 10:16:08 in mysql? I want to change how these values are saved. Is it possible or I will just l

5条回答
  •  迷失自我
    2021-01-26 02:45

    Don't change the way how these values are saved. Change the way they are output.

    See TIME_FORMAT()

    In your case, this would show a TIME field as 10:16:08 PM:

    SELECT TIME_FORMAT(timefield, "%l:%i:%s %p") AS date_formatted;
    

提交回复
热议问题