How to leave the date with Brazilian standard in Codeigniter 3?

2

I'm developing an application that takes the registration date of the registry. But is getting the date with American standard YYYY / mm / dd how do I correct this in codeigniter?

Here is an example of my code.

minha página html

     <div class="row clearfix">
        <div class="col-lg-2 col-md-2 col-sm-4 col-xs-5 form-control-label">
            <label for="cadastro">Cadastro</label>
        </div>
        <div class="col-lg-8 col-md-10 col-sm-8 col-xs-7">
            <div class="form-group">
                <div class="form-line">
                    <input type="text" id="cadastro" name="cadastro" class="form-control" required>
                </div>
            </div>
        </div>
    </div>

My controller is like this

if($this->input->post('submit')){
        $this->form_validation->set_rules('cadastro', 'Cadastro', 'trim|required');

        if ($this->form_validation->run() == FALSE) {
            $dados['view'] = 'admin/properties/properties_add';
            $this->load->view('layout', $dados);
        }
        else{
            $dados = array(
                'cadastro' => date('Y-m-d : h:m:s'),
            );
       }
    
asked by anonymous 05.12.2018 / 20:33

1 answer

2

You could implement it as follows:

else{
    $dados = date("d-m-Y", strtotime($data_que_esta_no_array));    
);

Useful links:

Date

strtotime

    
05.12.2018 / 20:50