0

I have dates in the following format:

2016-10-12
|    |  |
YEAR M  D

and I need:

12.10.16
|  |  |
D  M  YEAR

I have managed to parse date in source format:

$date = date_parse_from_format('YYYY-mm-dd', $dateYYYYMMDD);

But I am having trouble converting it to a new format. Could you please help.

Denis Kulagin
  • 8,472
  • 17
  • 60
  • 129

1 Answers1

0

Most flexible is to use the Datetime class:

<?php
$date = new Datetime('2016-10-12');
var_dump($date->format('d.m.y'));

The output obviously is:

string(8) "12.10.16"
arkascha
  • 41,620
  • 7
  • 58
  • 90