Hello All
Please find my following code containing three combo boxes with hours,mins and am pm when the page first displays firstcombo box current hour,2nd combo box current minutes third combo box if am or pm what ever should be displayed and the same should be displayed in the below. i will change the time and press submit will be displayed below.
what i am getting is 0 in the hours current minutes for example 56 and pm in the combo box .But PM is repeated twice
Please help m to solve my code
<?php
echo "<form method='post' action='time3.php?action=submit'>";
$time=date('H:i:s'); // Current Time
$ctime=explode(':',$time);
$h= $ctime[0];
if ($h > 12)
{
$h1=$h - 12;
}
echo "<select name=hours>";
for($i=0;$i<12;$i++)
{
if($i==$ctime[0])
{echo "<option value=$i selected>$i </option>";}
else
{ echo "<option value=$i>$i </option>";}
}
echo "</select>";
echo ' Mins';
echo "<select name=mins>";
for($i=0;$i<60;$i++)
{
if($i==$ctime[1])
{echo "<option value=$i selected>$i</option>";}
else
{ echo "<option value=$i>$i</option>";}
}
echo "</select>";
$h= $ctime[0];
if($h < 12)
{
//echo $h;
$am="AM";
}
else
{
// echo $h;
$am="PM";
}
echo " <select name=ampm>";
echo "<option value=AM>$am</option>";
echo "<option value=PM>$am</option>";
echo "</select>";
echo "</td></tr><tr><td height=7></td></tr>";
//echo "<tr><th colspan=2>Do You want to set this task as repeatitive task<input type=radio name=repeat value=1>Yes<input type=radio name=repeat value=0 checked>No</th></tr>";
?>
<tr><td height=7></td></tr>
<tr><td colspan=2 align=center><input type=submit value=submit></td></tr>
</form>
<?php
if(isset($_GET['action']) && !empty($_GET['action']))
{
$hours=$_POST['hours'];
$minutes=$_POST['mins'];
$ampm=$_POST['ampm'];
echo "$hours :"." $minutes"." $ampm";
}
?>