用经络将时间分成几小时和几分钟

Since in the form in an html has an input type time. Then it displays the 24 hours or military time. Then how should 24 hour time into 12 hour time with the meridians (AM and PM)? And how can I split the input type time into hours and minutes with meridians (AM and PM)?

This is DEMO

Using Javascript can be done..

 var dt = new Date();
    var h=dt.getHours();
    var time = dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds();
    alert(time);
    if(h<12)
    {alert(time+":AM");
    }else
    {
        alert(time+":PM");}
$format_timestamp=date("h:i A", strtotime($_POST['my_input'])); 

echo $format_timestamp;

$_POST['my_input'] is the input value you take from the user.

$time = '19:24:00'; //input of user
 $yourtime =  date('h:i a', strtotime($time)); //convert to 12 hours
preg_match("/([0-9]{1,2}):([0-9]{1,2}) ([a-zA-Z]+)/", $yourtime, $match); // split the hour and min and am/pm 
$hour = $match[1];
$min = $match[2];
$ampm = $match[3];

print_r($hour.':'.$min.':'.$ampm); //output

For Sever side time you can use PHP code as below.

<?php
    echo $time = date("h:i A");
?>

For client side time you can use javascript code as below

<script>
var dt = new Date();
var h=dt.getHours();
var time = dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds();

if(h<12)
{
   alert(time+":AM");
}
else
{
   alert(time+":PM");
}

both solutions give diffrent time as per required.