0

iam student have homework codeigniter. i want to creat form input student, and i have input date in that form. i used this code for input date:

<input type="date" class="form-control" name="seminar_proposal"
  value="<?php echo $seminar_proposal; ?>" required>

that form have format date dd-mm-yy but mysql have format yyyy-mm-dd then data mysql doesn't change. i used Controller, Model, and Views to call that form input can you help me what and where can i add function or code to convert them?. i really hope the answer :) thanks in advance

Anton Shchyrov
  • 285
  • 3
  • 15
ara
  • 11

1 Answers1

0

You have to convert when output date

<input type="date" class="form-control" name="seminar_proposal"
  value="<?php echo date('d-m-y', $seminar_proposal); ?>" required>

and convert string when process

$mysql_date = DateTime::createFromFormat(
  'd-my-y', $_GET['seminar_proposal'])->format('Y-m-d');
Anton Shchyrov
  • 285
  • 3
  • 15