更改php中的日期格式[关闭]

I have got date store in my database in datetime format,whereas in my view page I need to display date in different format.

My current query in model is-

function get_date($id)

{

 $query=$this->db->query("select `created_time` from `comments` where        `post_id`=$id");
$query2= $query->result_array();
$date=$query2['0']['created_time'];

 return $date;   
        }

result on view page: 2013-09-10 07:22:00 which is correct but what I want is:

10 sep 13

now can anyone please help me how to change the result to this format.

Just use strtotime to convert your date into a unix timestamp, and then use date to format it how you want:

<?php
    $date = '2012-02-06 22:20:37';
    $date = date('j M y', strtotime($date));
    var_dump($date); //6 Feb 12
?>

DEMO

And if you absolutely want it lowercase, just surround it by strtolower.