Structur-field get date

Hello,

how to formating a date string from a structur field ?

 <?php 
          $exposition_data = $page->exposition()->yaml();
          $exposition_count = $page->exposition()->toStructure()->count();
          foreach($exposition_data as $exposition_data_list):
            
            //echo $exposition_data_list[date_e];

          echo date('Y',$exposition_data_list[date_e]);
        
            echo $exposition_data_list[name_e];
            echo $exposition_data_list[location_e];
            echo $exposition_data_list[galerie_e];
            

          endforeach ?>

output

1970

blueprint

  exposition:
      label: Exposition
      type: structure
      style: table
      fields:
        date_e:
          label: Date
          type: date
        name_e:
          label: Name
          type: text
        galerie_e:
          label: Galerie
          type: text
        location_e:
          label: Location
          type: text
<?php echo date('Y', strtotime($exposition_data_list['date_e'])) ?>

https://getkirby.com/docs/cookbook/the-structure-field

BTW Your indices are missing quotes…

Thank you @pixelijn

indices are missing quotes

what do you mean by that ?

Maybe it works without, but the index of an array item should have quotes around it if it is not a number:

echo $exposition_data_list['name_e'];

instead of

echo $exposition_data_list[name_e];

The latter will probably work, but should throw a notice.

Oh! yes thanks @pixelijn

php is sooo tolerant :slight_smile: