Pluck dates change date format

Hello,

I used the pluck method on datefields to show similar dates.
The datefield is into a txt file attached to a file, a picture (1 date per file).
The pluck method is working but it change the date format “d.m.Y” to “Y.M.D”.
So it should be 21.03.2017 but the format is 2017.03.21

When I don’t use the pluck method the format is correct.
Here is the code:

<?php foreach($pages->find('collec')->files()->pluck('year', null, true) as $item): ?>
              <?php echo $item ?>
<?php endforeach ?>

this work for the format, but obviously it doesn’t pluck the values:

<?php foreach($pages->find('collec')->files() as $item): ?>
         <?php echo $item->date('d.m.Y', 'year') ?>
 <?php endforeach ?>

I saw some topics on the forum about the pluck method and dates but it doesn’t seem to work for me.
Did someone had a similar issue or have any advice on how to solve this?
Thanks !

Try this:

<?php echo date('d.m.Y', strtotime($item)) ?>

Oh, btw, your code will be much more readably in the future if you wrap code blocks within three backticks (```) on a separate line before and after a code block. Thank you very much!

Thank you very much texnixe it works !!

I will take care of the backticks in the future!