havish
10-15-2012, 05:05 PM
I need to insert into my database, the date and time of the user's pc and not the server. For this I am giving a textbox to the user to select date. But I do not know how to select the time at the time of hitting the submit button. The date field in my table is of datetime type. So the date is getting inserted through post method which is shown below. I need to know how can I insert time also..
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.0/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#datepicker').datepicker({
dateFormat: 'yy-mm-dd',
changeMonth: true,
changeYear: true});
});
</script>
echo '<form action="" method="post">
Please select date :<input name="date" id="datepicker" type="text" />
<input type="submit" name ="submit2" id="submit2" value ="submit"/></form>';
$date = $_POST['date'];
$query = "INSERT INTO `samp`(`date`) VALUES ('".$date."')";
mysql_query($query);
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.0/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#datepicker').datepicker({
dateFormat: 'yy-mm-dd',
changeMonth: true,
changeYear: true});
});
</script>
echo '<form action="" method="post">
Please select date :<input name="date" id="datepicker" type="text" />
<input type="submit" name ="submit2" id="submit2" value ="submit"/></form>';
$date = $_POST['date'];
$query = "INSERT INTO `samp`(`date`) VALUES ('".$date."')";
mysql_query($query);