Converting mysql TIME from 24 HR to AM/PM format

后端 未结 5 526
南旧
南旧 2020-12-17 14:37

I want to display the TIME field from my mysql table on my website, but rather than showing 21:00:00 etc I want to show 8:00 PM. I need a function/code to do this or even an

5条回答
  •  [愿得一人]
    2020-12-17 15:10

    I had been trying to do the same and got this page returned from a Google search. I worked a solution for the time 21:00:00;

    • using DATE_FORMAT(,'%l.%i%p') which returned 9.00PM

    • putting a LOWER() function around it to return 9.00pm

    So the full code is; DATE_FORMAT(,'%l.%i%p')

    Worked OK for me ...

提交回复
热议问题