Hi,

I was wondering if any of you have had any encounters with the Date formatting in Drupal 8, and have had any success overriding the default display in code? I'm aware that you can add new date and time formats, but that doesn't help me when I'm trying to output a date field in code and it's constantly using the standard display format as summarised in the Date class below located in Date.php.

class Date extends FormElement {
  /**
   * {@inheritdoc}
   */
  public function getInfo() {
    $class = get_class($this);
    return [
      '#input' => TRUE,
      '#theme' => 'input__date',
      '#process' => [[$class, 'processDate']],
      '#pre_render' => [[$class, 'preRenderDate']],
      '#theme_wrappers' => ['form_element'],
      '#attributes' => ['type' => 'date'],
      '#date_date_format' => 'Y-m-d',
    ];
  }
}

Would a preprocess function be the best option here? I can't figure out how best to reformat the default #date_date_format variable. Any guidance on this would be greatly appreciated. I'm not having any luck with the docs.

Thanks,
Mark.