I am trying to display Indian time in a text box using PHP , my script is working but there is no 'AM' or 'PM' . I am getting the time with AM or PM when i am using echo statement . Help me please .....


this is the screen shot - [img]http://i25.tinypic.com/dphmjo.png[/img]

<body>

<?php
$time_now = mktime( date('h')+5, date('i')+30, date('s') );
$gmt1 = date('h:i:s A', $time_now);
echo $gmt1; 
?>

<br> 
<br>


<input name="textfield" type="text" disabled="True" value= <?php echo $gmt1; ?>  >

      
</body>

A simple html error. Try this:

<body>
<?php
$time_now = mktime( date('h')+5, date('i')+30, date('s') );
$gmt1 = date('h:i:s A', $time_now);
echo $gmt1; 
?>
<br> 
<br>
<input name="textfield" type="text" disabled="True" value="<?php echo $gmt1; ?>"  >
</body>

thanks for u r help , now its working . Can u tell me what is the error ..

thanks for u r help , now its working . Can u tell me what is the error ..

The error was two quotation marks that needed adding in the following line.

<input name="textfield" type="text" disabled="True" value= <?php echo $gmt1; ?>  >

above was replaced with below

<input name="textfield" type="text" disabled="True" value="<?php echo $gmt1; ?>"  >

Very very minor but with different results.

thanks for u r help , one more thing how to display in the following fromat.....

11:30 AM Sunday , August 25 , 2009

thanks for u r help , one more thing how to display in the following fromat.....

11:30 AM Sunday , August 25 , 2009

Try this:

<body>
<?php
$time_now = mktime( date('h')+5, date('i')+30, date('s') );
$gmt1 = date('h:i:s A l, F j, Y', $time_now);
echo $gmt1; 
?>
<br> 
<br>
<input name="textfield" type="text" disabled="True" value="<?php echo $gmt1; ?>"  style="width: 256px;">
</body>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.