I am trying to store the date as NULL when user not entering any value from datepicker
DatePicker HTML
<div class="form-group">
<label >Date of Birth</label>
<!-- <input type="date" class="form-control" id="ac_date_of_birth" name="ac_date_of_birth" placeholder="Enter Date"> -->
<input type="text" class="form-control " id="ac_date_of_birth" name="ac_date_of_birth" tabindex="2" placeholder="Enter Date">
</div>
datepicker JS
$('#ac_date_of_birth').datepicker({
uiLibrary: 'bootstrap4',
format:'dd/mm/yyyy'
});
At Front end my date Format is dd/mm/yyyy like 25/04/2019 and I converted it to YY/mm/dd to store in Mysql Database
Here is my Codeigniter Code
$userInfo = $this->input->post();
$ac_date_of_birth = strtotime($userInfo['ac_date_of_birth']);
if (empty($userInfo['ac_date_of_birth'])) {
$ac_date_of_birth=NULL;
} else {
$ac_date_of_birth = str_replace('/', '-', date('Y-m-d', strtotime($userInfo['ac_date_of_birth'])));
}
I want to store NULL in case user not select date or when the select selected date will be store currently, it stores 1970/01/01