troubleshooting Question

Formatting mySQL Time Field with PHP?

Avatar of CynderWolve
CynderWolve asked on
4 Comments1 Solution912 ViewsLast Modified:
I have a PHP program that pulls from a mySQL database.  There is a Time field, which is automatically stores the data in a HH:MM:SS format.  However, I want to drop the seconds, so I display the information only in a HH:MM format.

I tried using the date() format function, with the time from the database placed in as the variable - but it came off as an incorrect time, and I'm not sure why.  So then I started thinking I could just remove the last three characters - the last :00 .  But I am having troubles figuring out how to do this.

So how do I do this?  I'd prefer learning about how to ge the date() function to work with a time field, since that will give me more flexibility in the long run.  However, learning how to trim off the last three characters would also be useful.


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros