Welcome Guest, Not a member yet? Register   Sign In
adding datetime in mysql with codeigniter
#1

[eluser]dhaulagiri[/eluser]
hello friends,

how do i add datetime ( not current timestamp) but any date and time in 'datetime' field of mysql database in the format 2011-03-18 18:37:06 from php ? does jquery calendar allow time as well or what is the easy way to do so ? any help would be greatly appreceated. Thanks
#2

[eluser]Total Shop UK[/eluser]
You mean like
Code:
date('Y-m-d H:i:s',strtotime($date))
#3

[eluser]InsiteFX[/eluser]
Code:
public function add_post()
{
    $now = date("Y-m-d H:i:s");

    $data = array(
    'title'        => $this->input->post('title'),
    'tags'        => $this->input->post('tags'),
    'status'    => $this->input->post('status'),
    'body'        => $this->input->post('body'),
    'category_id'    => $this->input->post('id'),
    'user_id'    => $this->session->userdata('user_id'),
    'pub_date'    => $now
    );

    $this->db->insert('posts', $data);
}

See pub_date

InsiteFX
#4

[eluser]dhaulagiri[/eluser]
what if i want to add date and time for 1 week later or after 25 days later , i am not talking abt timestamp, i want to add date and time for later than NOW()
#5

[eluser]osci[/eluser]
You can use mktime function to create manually the timestamp you need.
Then you'll use date function as insiteFX posted with extra argument the value returned by mktime.




Theme © iAndrew 2016 - Forum software by © MyBB