0

Here's my date format using to insert into database and in front end also displaying same. But I want to change in front end like d M yy format.

$postedon = date('Y-m-d',strtotime($this->input->post('postedon')));

output is Posted on : 2014-06-01

Here date is inserting and displaying like 2014-06-01.... but, if I change date format like this

$postedon = date('d M yy',strtotime($this->input->post('postedon')));

it is inserting as 0000-00-00.

So please guide me how to change format of date.

some_other_guy
  • 3,364
  • 4
  • 37
  • 55
user3496799
  • 7
  • 2
  • 8

1 Answers1

0

You can build two functions for date, to store in database and to display

here's the example

function us_date_formate_To_mysql($date){
    $date = str_replace("'", "", $date);
    $date = explode("/",$date);
    return $date = $date[2]."-".$date[0]."-".$date[1];
}

Arrange date as you want to show or save in your system.

Hope this will work for you.

Gwenc37
  • 2,064
  • 7
  • 18
  • 22