convert 24 hour time format to 12 hour time format

Posted on 2005-04-24
Last Modified: 2008-01-09
i want to convert a 24 hour format like 23:11:17 to a 12 hr format 12:09:01 PM

can this be done with a function already in php?
Question by:aot2002
    LVL 14

    Accepted Solution

    Not a built-in one as far as I know, but this is quite easy:

    echo date('g:i:s A' , strtotime("23:11:17")); // Replace the value in strtotime with a variable in the same format and it will still work
    LVL 2

    Expert Comment

    echo date(" g:i A");
    LVL 1

    Author Comment

    wow thanks so much dude
    LVL 14

    Expert Comment

    You're welcome :)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Suggested Solutions

    As this topic comes over and over again in different forms, I've finally decided to write a short (yea, right...) article / tutorial about pagination with PHP with MySQL database. There are dozens of these kind of tutorials, I know - I wanted to mak…
    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…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    761 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

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now