php datepicker problem

i am a newbie. Tired of searching through net if someone could help me. How to insert the date value through js datepicker showing the user in “dd-mm-yyyy” format.

date.html


save.php


  <?php

$host=“localhost”;
$username=“root”;
$password="";
$databasename=“saving”;
$conn = mysql_connect($host,$username,$password) or die(“cannot connect database”);

mysql_select_db($databasename,$conn) or die (“cannot find database”);

$thedate = stripslashes(trim ($_POST[‘thedate’]));
$select_record =“select * from only where thedate =’”.$thedate."’";

$select_query = mysql_query($select_record) or die (mysql_error());
if (mysql_numrows($select_query)==0)
{
$thedate = stripslashes(trim($_POST[‘thedate’]));
$add_new = “insert into only (thedate) values (’$thedate’)”;
$add_query = mysql_query($add_new) or die (mysql_error());
if ($add_query)
{
echo “New Record Added !!”;
}
}
else
echo “Not Added”;
?>

Found the answer on the jQuery UI datepicker documentation page (modify their example below to suit your needs).

Initialize a datepicker with the dateFormat option specified.
$( ".selector" ).datepicker({ dateFormat: "yy-mm-dd" });

Get or set the dateFormat option, after init.

//getter
var dateFormat = $( ".selector" ).datepicker( "option", "dateFormat" );
//setter
$( ".selector" ).datepicker( "option", "dateFormat", "yy-mm-dd" );</blockquote>

Source: http://jqueryui.com/demos/datepicker/

Thanx for the reply. but if you could help me out a little bit more. i’m new to javascript.

okay got it…thanx a lot.

Sponsor our Newsletter | Privacy Policy | Terms of Service