Welcome Guest, Not a member yet? Register   Sign In
My date when leave blank still save this format in my db:1970-01-01
#1

[eluser]Wondering Coder[/eluser]
first of all, morning and hi to all CI fans.

Code:
$save_project = $this->input->post('save_project');
        
            if($save_project)
            {
                $project_info = array(
                    't_id' => $this->session->userdata('user_id'),
                    'proj_title' => $this->input->post('project_title'),
                    'proj_description' => $this->input->post('description'),
                    'proj_deadline' => date('Y-m-d',strtotime($this->input->post('proj_deadline'))),                
                    'docu_date' => date('Y-m-d',strtotime($docu_date)),
                    'ref_date' => date('Y-m-d',strtotime($this->input->post('ref_date'))),
                    'photos_date' => date('Y-m-d',strtotime($this->input->post('photos_date'))),
                    'videos_date' => date('Y-m-d',strtotime($this->input->post('videos_date'))),
                    'documentation' => $this->input->post('docu'),
                    'reflection' => $this->input->post('ref'),
                    'photos' => $this->input->post('photos'),
                    'videos' => $this->input->post('videos'),
                    'display' => 1
                );
                    $this->admin_db->save_project($item,$project_info);
                    //redirect('admin/projects');
            }

I have this code above that save the data's in my db. As you can see I have 5 dates, and a user
can choose to select a date or not. Now my problem is when the user submit/save the data's and
the date's leave as blank in my db it still save this format date: 1970-01-01

I have this date type in my db:
Code:
CREATE TABLE IF NOT EXISTS `spms_project` (
  `documentation` tinyint(1) NOT NULL DEFAULT '0',
  `docu_date` date NOT NULL DEFAULT '0000-00-00',
  `reflection` tinyint(1) NOT NULL DEFAULT '0',
  `ref_date` date NOT NULL DEFAULT '0000-00-00',
  `photos` tinyint(1) NOT NULL DEFAULT '0',
  `photos_date` date NOT NULL DEFAULT '0000-00-00',
  `videos` tinyint(1) NOT NULL DEFAULT '0',
  `videos_date` date NOT NULL DEFAULT '0000-00-00',
  `display` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`proj_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;

and also I'm using a js calendar library, don't know if my calendar lib is causing this but I've looked in it,doesn't have a default date that will save 1970-01-01.


Messages In This Thread
My date when leave blank still save this format in my db:1970-01-01 - by El Forum - 06-19-2011, 07:58 PM



Theme © iAndrew 2016 - Forum software by © MyBB