Help with date when ordering

1

I have a field in the table that is set to dtConcat2 timestamp CURRENT_TIMESTAMP and in insert it takes the date of the server and writes in that field, the problem when I print the invoice the date field goes like this: Order Date: 03 10:32:49/12/2017

My code looks like this:

<strong>Data do Pedido:</strong>
<?php      
        echo implode('/',array_reverse(explode('-',$detalhe['dtConcat2'])));
?>

The time is between the day and the month, how do I correct this to print the date correctly?

    
asked by anonymous 03.12.2017 / 13:40

2 answers

0

I believe that in your field the format is date and time, so first is to extract the date and then with the date format the output as you want, eg:

<strong>Data do Pedido:</strong>
<?php      
   $data_hora = explode(' ',$detalhe['dtConcat2']);
   echo implode('/',array_reverse(explode('-', $data_hora[0])))." ".$data_hora[1];
?>

there is a way that is date_format by formatting exit of your direct date in SQL of bank MySQL example:

SELECT *, DATE_FORMAT(dtConcat2, '%d/%m/%Y %H:%i:%s') as dtConcat2Formatada FROM table;

For example, I'd rather format the output in SQL .

References

03.12.2017 / 13:48
-1

You explode the hour before, through space ...

$data = explode(" ", $detalhe['dtConcat2']);
echo implode('/',array_reverse(explode('-',$data[0])))." ".$data[1];
    
03.12.2017 / 13:50