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

Asked

Viewed 125 times

2

Folks I’m developing an application that picks up the registration date from the register. But it’s picking up the date with American standard YYYY/mm/dd as I fix it in codeigniter ?

Follow 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'),
            );
       }

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.