我一直在尝试将datepicker的格式从默认值更改为yy-mm-dd
,但它没有生效。我将在下面添加我的代码以供进一步参考。感谢
HTML:
<input type="text" id="datepicker" name="call_date" class="form-control">
javascript如下:
JAVASCRIPT:
<script type="text/javascript">
$(function() {
$( "#datepicker" ).datepicker({dateFormat: 'yy-mm-dd');
});
</script>
dateFormat似乎是正确的,但不知何故它没有生效,我的数据库插入了零,即0000-00-00
。任何帮助将非常感激。感谢
编辑: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);
答案 0 :(得分:3)
您的日期格式未被应用,因为您错过了日期格式块中的右括号'}'
,因此格式仍然是默认格式,即dd / mm / yy,就像您在评论中提到的那样。
将此datepicker({dateFormat: 'yy-mm-dd');
更改为此datepicker({dateFormat: 'yy-mm-dd'});
这是推杆后的Working Fiddle。
JAVASCRIPT :
<script type="text/javascript">
$(function() {
$( "#datepicker" ).datepicker({dateFormat: 'yy-mm-dd'});
});
</script>