0

I have a question for you I try but not received...I need to insert date into database: My script:

 <script>
 $(document).ready(function() {
     $("#datepicker").datepicker({
         format: 'yyyy-mm-dd'
     });
 })

My html:

<div class="form-group">
     <label>Date:</label>
     <input class="form-control marg-left-10" name="date" id="datepicker">
</div>

My php:

$date = date('Y-m-d H:i:s', strtotime($this->input->post['date']));

data is inserted into database : 1962-12-31. Please help me.

1
  • can you print this value $this->input->post['date']? Commented Aug 25, 2014 at 13:23

2 Answers 2

2

Try to replace

$this->input->post['date']

to

$this->input->post('date')

For more :- https://ellislab.com/codeigniter/user-guide/libraries/input.html

Sign up to request clarification or add additional context in comments.

Comments

1

I suggest to use DateTime::createfromformat(string $format , string $time). Ie:

$date = DateTime::createFromFormat("Y-m-d", $this->input->post('date'));
$stringDate = $date->format("Y-m-d H:i:s");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.