1

I have times stored in the database in this format

09:30:00

And of course I can display them on the page in that format. But how do I display it in the following format?..

9.30am

I have looked for a solution but can't find anything that does just this.

user2227359
  • 317
  • 1
  • 4
  • 13
  • You can either format date in you mysql select ... or in php. I let you do a bit of research and come back if needed. – Cyrbil Jul 08 '15 at 16:12

2 Answers2

1

Use the date() function to convert time formats.

$time = date("g:ia", strtotime("09:30:00"));

Broken down time formatting:

  • g - Hours in 12 hour format
  • : - Colon character
  • i - Minutes with leading zeros
  • a - am or pm

See the manual.

Jamie
  • 467
  • 8
  • 19
1

try this,

$timeval = date("g:i a", strtotime("09:30:00"));