jquery ui datepicker take value 1970 if input field is blank

☆樱花仙子☆ 提交于 2019-12-11 02:53:57

问题


i am using jquery ui date picker for take fromDate and toDate

Following is the code of from date

 <input name="from_date" id="from_date" maxlength="20" size="20" type="text"/>  

   $("#from_date").datepicker({
            dateFormat: 'M dd, yy',
            showButtonPanel: true,
            changeMonth: true,
            changeYear: true,
            defaultDate: null
        });   

now i use the form to take the value in POST varible using PHP
If the fromDate field is blank then it take value '1970-01-01' i want it blank


回答1:


Change your PHP function is use empty instead of null

function showDate($date,$format='m-d-y, h:i a') {
   if(empty($date)) return ' ';
   return date($format,strtotime($date)); 
}



回答2:


try to set defaultDate: '' or remove it at all




回答3:


As you can find in jquery ui documentation (here), if you don't precise defaultDate option, default date is current date.



来源:https://stackoverflow.com/questions/7978787/jquery-ui-datepicker-take-value-1970-if-input-field-is-blank

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!