0

I am trying to convert a date from my database into a different format, but for some reason it's not showing the correct time.

This is the date in the database:

17/06/2015

I'm using this code and its outputing this:

1970-01-01

This is the code I've tried so far, but as you can see it's outputting the incorrect date:

$date = str_replace('/', '-', "17/06/2015");
$date = date('Y-m-d',strtotime("17/06/2015"));

echo $date;
thanksd
  • 54,176
  • 22
  • 157
  • 150

1 Answers1

0

Try this I get the correct result from following code

$date = "17/06/2015";
$repDate = str_replace('/', '-', $date);
$newDate = date("Y-m-d", strtotime($repDate));
echo $newDate;
Syed mohamed aladeen
  • 6,507
  • 4
  • 32
  • 59