[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

convert 24 hour time format to 12 hour time format

Posted on 2005-04-24
4
Medium Priority
?
10,109 Views
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?
0
Comment
Question by:aot2002
  • 2
4 Comments
 
LVL 14

Accepted Solution

by:
cracky earned 1000 total points
ID: 13856179
Not a built-in one as far as I know, but this is quite easy:

<?php
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
?>
0
 
LVL 2

Expert Comment

by:Marvin_Carredo
ID: 13856189
echo date(" g:i A");
0
 
LVL 1

Author Comment

by:aot2002
ID: 13872915
wow thanks so much dude
0
 
LVL 14

Expert Comment

by:cracky
ID: 13873408
You're welcome :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month20 days, 1 hour left to enroll

872 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