Sunday, 15 August 2010

php - Inserting created_at data with Laravel -



php - Inserting created_at data with Laravel -

i cannot seem insert created_at info in database table laravel. i'm trying info post request , trying save database.

i'm doing this:

$create_dt = date("y-m-d h:i:s a", strtotime($_post['post_date']." ".$_post['post_time'])); $name = $_post['name']; $post = new post(); $post->name = $name; ... $post->created_at = $create_dt; $post->save();

but error shows saying

uncaught exception 'invalidargumentexception' message in carbon.php

and

unexpected info found. unexpected info found. info missing in carbon.php

how solve this? have set $timestamps in models false? (i don't wanna because i'm fine how automatically inserts updated_at)

in user model, add together next line in user class:

protected $timestamps = true;

now, whenever save or update user, laravel automatically update created_at , updated_at fields.

update: if want set created @ manually should utilize date format y-m-d h:i:s. problem format have used not same laravel uses created_at field.

php datetime laravel laravel-4

No comments:

Post a Comment