Jump to content

Date format problem


rajaahsan

Recommended Posts

Hy every one i have this two file code one is index.php and second is insert.php

 

here is index.php code ,

 

<html>
<body>

<form action="insert.php" method="post">
Time <input type="text" name="time" />
<input type="submit" />
</form>

<?php
$ctime = date('h:i:s A');
echo "Current time is : " . $ctime ;
echo "<br>";

$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("time", $con);

$result = mysql_query("SELECT * FROM time");

while($row = mysql_fetch_array($result))
  {
  echo $row['time'];
  echo "<br />";
  }

mysql_close($con);
?> 


</body>
</html> 


here is insert.php code ,

<?php
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("time", $con);

$sql="INSERT INTO time (time )
VALUES
('$_POST[time]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";
echo "<br>";
echo "<a href='index.php'>Home</a>";

mysql_close($con)
?>

 

This code work fine but when it returns me the ouput in this format

 

Time  (inputbox)  submit

 

Current time is : 07:25:53 PM

 

10:55:00

10:55:00

 

 

i saved one value with 10:55 AM in my field box and one value with 10:55 PM but no effect what is the problem i want to display the output as like this,

 

10:55:00 AM

10:55:00 PM

 

Hope you understand what i want...

thanks

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.