I have tried so many possible solutions and it's just not working for me. I have the following code:
<div class="bootstrap-iso">
<div class="container-fluid">
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-12">
<!-- datepicker code begins -->
<div class="form-group"> <!-- Date input -->
<label class="control-label" for="date">Closing Date</label>
<input class="form-control" id="date" name="date" placeholder="YYYY- MM-DD" type="date"/>
</div>
</div>
</div>
</div>
Then I have the follownig:
<script>
$(document).ready(function(){
var date_input=$('input[name="date"]'); //our date input has the name "date"
var container=$('.bootstrap-iso form').length>0 ? $('.bootstrap-iso form').parent() : "body";
var options={
format: 'yyyy-mm-dd',
container: container,
todayHighlight: true,
autoclose: true,
};
date_input.datepicker(options);
})
</script>
In my class I have the following code:
$newVacancy_stmt = $db->prepare('INSERT INTO vacancies (roleID, shortTitle, longTitle, roleDescription, roleResponsibilities, roleRequirements, createdBy, creationDate, publishDate, closeDate) VALUES (:roleID, :shortTitle, :longTitle, :roleDescription, :roleResponsibilities, :roleRequirements, :createdBy, NOW(), NOW(), ' . $closingDate . '))');
I convert my posted date with this:
$closingDate = date('Y-m-d', strtotime($_POST['date']));
Then I call my function:
$addVacancy = addNewVacancyInternal($roleID, $shortTitle, $longTitle, $roleDescription, $roleResponsibilities, $roleRequirements, $createdBy, $closingDate);
It does not insert the record into the DB. As soon as I take the date out (not inserting the date) it insert the record. Any suggestions please?
$db->prepare('INSERT INTO vacancies (roleID, ...., publishDate, closeDate)
VALUES (:roleID, .... NOW(), :closingDate))');
and pass $closingDate
with the rest of the named parameters.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.