0

I have a view, like this:

<div class="input-append date the_date">
    <input data-format="yyyy-MM-dd HH:mm:ss" type="text" readonly>
</div>

and js, like this:

var the_date = $('.the_date > input').val();
// [DATA FOR SERVER]:
var data={ the_date : the_date }

And when I submit the date form, the data array is sent to a controller which inserts the date via a model function.

However the selected date is NOT inserted to the database.

I can alert(the_date); from js, I can echo $the_date; from the controller and I can even echo $the_date; from the model, however $the_date does not go into the database.

I have a standard datetime field in MySQL called the_date which has the standard MySQL datetime format of "yyyy-MM-dd hh:mm:ss", and I can't figure out why the_date is not going into the db.

I am using CodeIgniter's Active Record for inserts, and every other insert works fine. I can insert dates with:

'the_date' => date("Y-m-d H:i:s")

for example, and I can also say:

'the_date' => '2002-11-11 12:12:12')

But the default datetime of "0000-00-00 00:00:00" is inserted everytime I use the datetimepicker from Bootstrap....

1
  • You'll need to share more code than this. You haven't even shown your controller code, or the Javascript code for making the request. Commented Apr 1, 2013 at 23:31

1 Answer 1

0

As @Cryode said, you have to give more code than that..

Im assuming the_date is a string of format '2002-11-11 12:12:12'. Have you tried something like:

date('Y-m-d H:i:s',strtotime(the_date))
Sign up to request clarification or add additional context in comments.

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.