1

I need to send data in json format, but to convert the date it loses the original formatting:

 $date =   date("d/m/Y", "1988-12-04 00:00:00");
 $teste = json_encode($date);
 var_dump($teste);exit;

I need this format: 04/12/1988, but print: string "01\/01\/1970" (length=14)

How to remove this bar?

Jonathan Bravetti
  • 2,228
  • 2
  • 15
  • 29
scooby
  • 207
  • 1
  • 12

1 Answers1

3

Use strtotime while changing date format.

$date =   date("d/m/Y", strtotime("1988-12-04 00:00:00"));
 $teste = json_encode($date);
 var_dump($teste);exit;
milan kyada
  • 579
  • 5
  • 15