问题
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