Hi All,

I'm working on a database wherein I want to input the current date into existing table upon
the user enter his pin. I'm having a hard time to make it work here is my code.

<?php
    $result="SELECT * FROM profiletable WHERE (firstName='$_POST[assetSearch]' || lastName='$_POST[assetSearch]' || IDNumber='$_POST[assetSearch]')";
    $q = mysql_query($result,$con);
		if($row = mysql_fetch_array($q))
			{
				 $d=date("Y/m/d");
				 $sql="INSERT INTO profiletable(IDNumber(date))
								   VALUES('$_POST[$d]')";
				 
				 echo "you are login";
			}
	mysql_close($con); 
    ?>

any help about this?thank you

Hi,

You can use the unix time if you want. Normally, more people are using this because the chance of duplicates is somewhat pretty rare. Think about having two people clicking the same button at the same time .

You can use like this

$time_posted = $time();

You can then use the $time_posted to be saved in your database.. Usually, you would get something like this 12674916644 bunch of numbers.

If you want to show it on the webpage as readable date and time, all you have to do is to convert back to its original form, before it became unix. Like this

echo date('l jS \of F Y h:i:s A', $time_posted);

You can also calculate the time since it was posted by using the current time as reference like this

## time elapsed since it was posted
$time_elapsed = (time() - ($time_posted));

echo $time_elapsed;
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.