• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Date resat as 01-01-1970 after update

#1
Hello everyone, 

I am try to update my member profile data & after updated, All dates in form (like Birth day) reset as  01-01-1970. Any one know the solution for this thing. this is my model,

PHP Code:
function update_member($id)
 
  {
 
      $now date_default_timezone_set('Asia/Colombo'); // Set Time-Zone
 
      $now date('Y-m-d H:i'); //Fomat Date and time


 
      $data['custom_member_id'] = $this->input->post("custom_member_id");
 
      $data['surname'] = $this->input->post("surname");
 
      $data['other_name'] = $this->input->post("other_name");
 
      $data['initials'] = $this->input->post("initials");
 
      $data['title'] = $this->input->post("title");
 
      $data['gender'] = $this->input->post("gender");
 
      $data['b_day'] =  date('m-d-Y'strtotime$this->input->post("b_day")));
 
      $data['join_date'] = date('m-d-Y'strtotime$this->input->post("join_date")));
 
      $data['last_renewal'] = date('m-d-Y'strtotime$this->input->post("renewal_date")));
 
      $data['status'] = $this->input->post("status");
 
      $data['membership_status'] = $this->input->post("membership_status");
 
      $data['created_by'] = $this->session->userdata("NAME");
 
      $data['created_at'] = $now;

 
      $this->db->where('id'$id);
 
      $this->db->update('membership'$data);


 
      $b_d['b_date'] = date('Y-m-d'strtotime$this->input->post("b_day")));

 
      $this->db->where('member_id'$id);
 
      $this->db->update('birth_day'$b_d);

 
  

This is my Controller,

PHP Code:
 function update_member_view($id)
 
   {
 
       if ($this->session->userdata("NAME"))
 
       {
 
           $role$this->session->userdata("ID");
 
           if ($role >=1)
 
           {
 
               if ($this->input->post())
 
               {
 
                   $this->form_validation->set_rules('surname''Surname Name''required');
 
                   $this->form_validation->set_rules('other_name''Names Denoted by Initials''required');
 
                   $this->form_validation->set_rules('initials''Initials''required');
 
                   $this->form_validation->set_rules('b_day''Date of Birth''required');
 
                   $this->form_validation->set_rules('address_01''Address Line - 01''required');
 
                   $this->form_validation->set_rules('city''City''required');
 
                   $this->form_validation->set_rules('zip_code''Zip Code''required');
 
                   $this->form_validation->set_rules('mobile''Mobile Phone''required');
 
               }
 
               if ($this->form_validation->run() == TRUE)
 
               {
 
                   $this->Membership_model->update_member($id);
 
                   redirect('membership/member_list');
 
               }
 
               $data["row"] = $this->Membership_model->update_member_view($id);
 
               if ($data["row"] == null)
 
               {
 
                   $this->load->view('includes/header');
 
                   $this->load->view('includes/top_header');
 
                   $this->load->view('includes/left_nav');
 
                   $this->load->view('error_page/404');
 
                   $this->load->view('includes/footer');
 
                   $this->load->view('includes/settings');

 
               }else
 
               {
 
                   $this->load->view('includes/header');
 
                   $this->load->view('includes/top_header');
 
                   $this->load->view('includes/left_nav');
 
                   $this->load->view('membership/update_member'$data);
 
                   $this->load->view('includes/footer');
 
                   $this->load->view('includes/settings');
 
               }
 
           }
 
           else{
 
               $this->session->set_flashdata('message_name''You did not have permission to access this page.');
 
               redirect('user/index');
 
           }
 
       }
 
       else{
 
           $this->session->set_flashdata('message_name''Your session has been expired. Please Login');
 
           redirect('login/employee_login');
 
       }
 
   

Please help me to resolve this error..
Reply

#2
date('d-m-Y', 0) = 01-01-1970 ...

Simply this means that there is zero value for date, either this zero comes from DB or from the post, which ever is displayed wrong..
Best VPS Hosting : Digital Ocean
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2018 MyBB Group.