Reputation: 667
I have been trying to change the datepicker's format from the default to yy-mm-dd
but it isn't taking effect. I will add my code below for further reference. Thanks
HTML:
<input type="text" id="datepicker" name="call_date" class="form-control">
And the javascript is below:
JAVASCRIPT:
<script type="text/javascript">
$(function() {
$( "#datepicker" ).datepicker({dateFormat: 'yy-mm-dd');
});
</script>
The dateFormat seems right but somehow it isn't taking effect and my database is getting inserted with zeroes, i.e 0000-00-00
. Any help would be much appreciated. Thanks
EDIT: INSERTION QUERY
$date = $_POST['call_date'];
$logqry = "INSERT INTO clinic_log(log_date,log_time,log_caller,log_reason,log_response)VALUES('$date','$time','$caller','$reason','$response')";
$logresult = mysqli_query($conn,$logqry);
Upvotes: 2
Views: 2931
Reputation: 2749
your dateformat isn't applied beacuse you missed closing bracket '}'
in the date format block,so the format is still the default one i.e. dd/mm/yy, like you mentioned in comment.
change this datepicker({dateFormat: 'yy-mm-dd');
to this datepicker({dateFormat: 'yy-mm-dd'});
here is the Working Fiddle after putting barcket.
JAVASCRIPT :
<script type="text/javascript">
$(function() {
$( "#datepicker" ).datepicker({dateFormat: 'yy-mm-dd'});
});
</script>
Upvotes: 3