Question: My intention is to convert the following date 

`20/04/17 13:27:5` 
to this 

`20-04-2017 13:27:05`

I tried the typical date format functions of php and also Carbon...

things like

```
$newDate= Carbon::createFromFormat('d/m/y H:m:s', $originalDate);

```

in this case 
`var_dump($newDate->toDateTimeString())` would bring `2019-03-20 13:00:55` which is not what I expect.

So I was not lucky....is there a way to do this in a straight forward manner?

Answer: 
There is issue with seconds. There must be `05` not only `5`

```
<?php

    $original_date = "20/04/17 13:27:5";
    $date_explode = explode(":", $original_date);
    $date_explode[2] = str_pad($date_explode[2],2,"0",STR_PAD_LEFT);
    $original_date = implode($date_explode,":");

    $date = DateTime::createFromFormat('d/m/y H:i:s', $original_date);
    echo date_format($date,"d-m-Y H:i:s");

?>

```
Isn't it like this?

```
$newDate = Carbon::createFromFormat('d/m/y H:i:s', $originalDate);

```