How to format time

Posted on 2010-09-14
Last Modified: 2012-05-10
$time = "08:00:00";  (Hour:Minute:Seconds)

How could I get rid of the two zeroes for second?
Question by:lericson
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Expert Comment

by:Sander Stad
ID: 33673117
LVL 31

Expert Comment

by:Marco Gasi
ID: 33673192
See if this makes sense for you:

$time ="08:00:00";
$mytime = str_replace(":","",$time);
echo date("h:m", $mytime);

LVL 31

Accepted Solution

Marco Gasi earned 500 total points
ID: 33679399
Sorry for mistake, this is correct:

echo date('h:i', strtotime("08:00:00"));


Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Why isn't my DIV and Form centering? 1 25
Help installing Laravel app on MAMP on MAC 7 53
Load string Array from file 23 37
php time 12 22
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question