1

In codeigniter before database insertion, datetime is correct.

05-08-2019 17:30:00

But in database it's 05-08-2019 5:30:00 I tried to add timestamp in config.php.

date_default_timezone_set('Asia/Kolkata');

But no change in this behavior.

3
  • can you show your date_format() code how you insert it in DB? Commented Aug 6, 2019 at 2:51
  • $data['cur_time']=date('y-m-d h:i:s'); $this->db->insert('tb_user', $data); Commented Aug 6, 2019 at 4:20
  • if you insert it from mysql timestamp auto update, then check your server timezone. Commented Aug 6, 2019 at 4:20

1 Answer 1

1

Try this,

$data['cur_time']=date('Y-m-d H:i:s');//changes `H` & `Y`
$this->db->insert('tb_user', $data);

H will give you Hour (00 to 23)
h will give you Hour (00 to 12)
Y Year as a numeric, 4-digit value
y Year as a numeric, 2-digit value

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

1 Comment

I think this will work. Will try by inserting new data this afternoon

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.