convert 24 hour time format to 12 hour time format

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?
LVL 1
aot2002Asked:
Who is Participating?
 
crackyCommented:
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
 
Marvin_CarredoCommented:
echo date(" g:i A");
0
 
aot2002Author Commented:
wow thanks so much dude
0
 
crackyCommented:
You're welcome :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.