Welcome Guest, Not a member yet? Register   Sign In
Trouble with DATE field and date/strtotime conversion
#3

[eluser]elambert[/eluser]
Sorry about that...
Code:
function get_by_user_id( $id )
{
  $this->db->where( ‘users_user_id’, (int)$id );
  $query = $this->db->get( ‘profiles’ );
  if ( $query->num_rows() > 0 )
  {      
    $row = $query->row_array();  
    $row[ ‘profile_date_birth’ ] = date( ‘m-d-Y’, strtotime( $row[ ‘profile_date_birth’ ] ) );        
  }
  return ( $query->num_rows() > 0 ) ? $row : FALSE;
}

In the model, I update a record with this function:

function update( $id, $data )
{
  $data[ ‘profile_date_birth’ ] = date( ‘Y-m-d’, strtotime( $data[ ‘profile_date_birth’ ] ) );              
  $this->db->where( ‘profile_id’, (int)$id );
  $query = $this->db->update( ‘profiles’, $data );        
  return ( $query ) ? TRUE : FALSE;                
}

When I run your code it produces: 2000-02-01


Messages In This Thread
Trouble with DATE field and date/strtotime conversion - by El Forum - 08-05-2011, 09:41 AM
Trouble with DATE field and date/strtotime conversion - by El Forum - 08-05-2011, 10:05 AM
Trouble with DATE field and date/strtotime conversion - by El Forum - 08-05-2011, 10:30 AM
Trouble with DATE field and date/strtotime conversion - by El Forum - 08-05-2011, 10:32 AM



Theme © iAndrew 2016 - Forum software by © MyBB