Twig date function not working on custom field within node Even if content.field_my_date contains a date like 2021-10-01, twigs date function outputs today's date when using {{ content.field_my_date|date("M.d.Y") }}. Simply printing {{ content.field_my_date }} to make sure the field isn't empty, outputs the correct date and label.
Before you need convert field field_my_date form 2021-10-01 to timestamp

You can use hook_ENTITY_TYPE_view_alter to be convert it to timestamp

use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;


/**
 * Implements hook_ENTITY_TYPE_view().
 */

function hook_ENTITY_TYPE_view_alter(array &amp;$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
  if($display-&gt;bundle()=='node_type'){
    $field_date_timestamp = strtotime($entity-&gt;get('field_my_date')- &gt;value);
    $build['field_my_date'] = \Drupal::service('date.formatter')-&gt;format(
    $field_date_timestamp, 'custom', 'M.d.Y');
  }
}


in file twig node tempalte {{field_my_date}}