Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display date format as DD MM YYYY in active record Codeigniter

How would I alter my active record to display my date as DD MM YYYY rather than YYYY MM DD?

Current Display

2016-01-07

Aim Display

07-01-2016

Current View

<?php echo $row->start_date; ?>

Tried View

<?php echo $row->DATE_FORMAT(start_date, '%d/%m/%Y'); ?>

Model

class Profiles_model extends CI_Model

    {

        function get_bank()
        {
            $this->db->where('mem_id', $this->session->userdata("id"));
            $query = $this->db->get('bank');
            return $query->result();
        }

    }
like image 693
Beep Avatar asked Dec 06 '22 18:12

Beep


1 Answers

You can use strtotime() and date() of php as :

$originalDate = $row->start_date;
$newDate = date("d-m-Y", strtotime($originalDate));
like image 106
Drudge Rajen Avatar answered Dec 09 '22 16:12

Drudge Rajen