diff --git a/core/modules/datetime_range/datetime_range.module b/core/modules/datetime_range/datetime_range.module
index 5263b2b9e271b01cc6fe020a0c02a7088ddc0a1f..6e3ca0dde7a5ea74962102cb7adeb6bef661f789 100644
--- a/core/modules/datetime_range/datetime_range.module
+++ b/core/modules/datetime_range/datetime_range.module
@@ -68,7 +68,7 @@ function datetime_range_entity_view_display_presave(EntityViewDisplayInterface $
 
     if (!isset($component['settings']['from_to'])) {
       // Existing daterange formatters don't have 'from_to'.
-      $component['settings']['from_to'] = DateTimeRangeConstants::BOTH;
+      $component['settings']['from_to'] = DateTimeRangeConstants::BOTH->value;
       $entity_view_display->setComponent($name, $component);
     }
   }
diff --git a/core/modules/datetime_range/src/DateTimeRangeConstants.php b/core/modules/datetime_range/src/DateTimeRangeConstants.php
index a8469b020a6693b362bf01e08f4bc6b9fde52363..9257b3e3823a1fe46cf71c7bd1b178617f6d2ae9 100644
--- a/core/modules/datetime_range/src/DateTimeRangeConstants.php
+++ b/core/modules/datetime_range/src/DateTimeRangeConstants.php
@@ -5,13 +5,13 @@
 /**
  * Declares constants used in the datetime range module.
  */
-interface DateTimeRangeConstants {
+enum DateTimeRangeConstants: string {
 
   /**
    * Values for the 'from_to' formatter setting.
    */
-  const BOTH = 'both';
-  const START_DATE = 'start_date';
-  const END_DATE = 'end_date';
+  case BOTH = 'both';
+  case START_DATE = 'start_date';
+  case END_DATE = 'end_date';
 
 }
diff --git a/core/modules/datetime_range/src/DateTimeRangeTrait.php b/core/modules/datetime_range/src/DateTimeRangeTrait.php
index c4a8a683f4805552a17dc7efa674e26e044b854a..8d7107a87c02edc1e8311b666feca6f4809b56b7 100644
--- a/core/modules/datetime_range/src/DateTimeRangeTrait.php
+++ b/core/modules/datetime_range/src/DateTimeRangeTrait.php
@@ -16,7 +16,7 @@ trait DateTimeRangeTrait {
    */
   protected static function dateTimeRangeDefaultSettings() {
     return [
-      'from_to' => DateTimeRangeConstants::BOTH,
+      'from_to' => DateTimeRangeConstants::BOTH->value,
       'separator' => '-',
     ];
   }
@@ -73,7 +73,7 @@ protected function dateTimeRangeSettingsForm(array $form, FormStateInterface $fo
       '#default_value' => $this->getSetting('separator'),
       '#states' => [
         'visible' => [
-          'select[name="fields[' . $field_name . '][settings_edit_form][settings][from_to]"]' => ['value' => DateTimeRangeConstants::BOTH],
+          'select[name="fields[' . $field_name . '][settings_edit_form][settings][from_to]"]' => ['value' => DateTimeRangeConstants::BOTH->value],
         ],
       ],
     ];
@@ -93,7 +93,7 @@ protected function dateTimeRangeSettingsSummary() {
       }
     }
 
-    if (($separator = $this->getSetting('separator')) && $this->getSetting('from_to') === DateTimeRangeConstants::BOTH) {
+    if (($separator = $this->getSetting('separator')) && $this->getSetting('from_to') === DateTimeRangeConstants::BOTH->value) {
       $summary[] = $this->t('Separator: %separator', ['%separator' => $separator]);
     }
 
@@ -108,9 +108,9 @@ protected function dateTimeRangeSettingsSummary() {
    */
   protected function getFromToOptions() {
     return [
-      DateTimeRangeConstants::BOTH => $this->t('Display both start and end dates'),
-      DateTimeRangeConstants::START_DATE => $this->t('Display start date only'),
-      DateTimeRangeConstants::END_DATE => $this->t('Display end date only'),
+      DateTimeRangeConstants::BOTH->value => $this->t('Display both start and end dates'),
+      DateTimeRangeConstants::START_DATE->value => $this->t('Display start date only'),
+      DateTimeRangeConstants::END_DATE->value => $this->t('Display end date only'),
     ];
   }
 
@@ -122,8 +122,8 @@ protected function getFromToOptions() {
    */
   protected function startDateIsDisplayed() {
     switch ($this->getSetting('from_to')) {
-      case DateTimeRangeConstants::BOTH:
-      case DateTimeRangeConstants::START_DATE:
+      case DateTimeRangeConstants::BOTH->value:
+      case DateTimeRangeConstants::START_DATE->value:
         return TRUE;
     }
 
@@ -138,8 +138,8 @@ protected function startDateIsDisplayed() {
    */
   protected function endDateIsDisplayed() {
     switch ($this->getSetting('from_to')) {
-      case DateTimeRangeConstants::BOTH:
-      case DateTimeRangeConstants::END_DATE:
+      case DateTimeRangeConstants::BOTH->value:
+      case DateTimeRangeConstants::END_DATE->value:
         return TRUE;
     }
 
@@ -162,13 +162,13 @@ protected function endDateIsDisplayed() {
   protected function renderStartEnd(DrupalDateTime $start_date, string $separator, DrupalDateTime $end_date): array {
     $element = [];
     if ($this->startDateIsDisplayed()) {
-      $element[DateTimeRangeConstants::START_DATE] = $this->buildDate($start_date);
+      $element[DateTimeRangeConstants::START_DATE->value] = $this->buildDate($start_date);
     }
     if ($this->startDateIsDisplayed() && $this->endDateIsDisplayed()) {
       $element['separator'] = ['#plain_text' => ' ' . $separator . ' '];
     }
     if ($this->endDateIsDisplayed()) {
-      $element[DateTimeRangeConstants::END_DATE] = $this->buildDate($end_date);
+      $element[DateTimeRangeConstants::END_DATE->value] = $this->buildDate($end_date);
     }
     return $element;
   }
@@ -189,13 +189,13 @@ protected function renderStartEnd(DrupalDateTime $start_date, string $separator,
   protected function renderStartEndWithIsoAttribute(DrupalDateTime $start_date, string $separator, DrupalDateTime $end_date): array {
     $element = [];
     if ($this->startDateIsDisplayed()) {
-      $element[DateTimeRangeConstants::START_DATE] = $this->buildDateWithIsoAttribute($start_date);
+      $element[DateTimeRangeConstants::START_DATE->value] = $this->buildDateWithIsoAttribute($start_date);
     }
     if ($this->startDateIsDisplayed() && $this->endDateIsDisplayed()) {
       $element['separator'] = ['#plain_text' => ' ' . $separator . ' '];
     }
     if ($this->endDateIsDisplayed()) {
-      $element[DateTimeRangeConstants::END_DATE] = $this->buildDateWithIsoAttribute($end_date);
+      $element[DateTimeRangeConstants::END_DATE->value] = $this->buildDateWithIsoAttribute($end_date);
     }
     return $element;
   }
diff --git a/core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php b/core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php
index bcefcc880da3721dfdb5c6c2d45bd619f50e7fa9..a00c705249418bc988e170442df61584f46195ed 100644
--- a/core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php
+++ b/core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php
@@ -38,7 +38,7 @@ class DateRangeFieldTest extends DateTestBase {
    *
    * @var array
    */
-  protected $defaultSettings = ['timezone_override' => '', 'separator' => '-', 'from_to' => DateTimeRangeConstants::BOTH];
+  protected $defaultSettings = ['timezone_override' => '', 'separator' => '-', 'from_to' => DateTimeRangeConstants::BOTH->value];
 
   /**
    * {@inheritdoc}
@@ -1507,44 +1507,44 @@ public function fromToSettingDataProvider() {
     $datetime_types = [
       DateRangeItem::DATETIME_TYPE_DATE => [
         'daterange_default' => [
-          DateTimeRangeConstants::START_DATE => '12/31/2012',
-          DateTimeRangeConstants::END_DATE => '06/06/2013',
+          DateTimeRangeConstants::START_DATE->value => '12/31/2012',
+          DateTimeRangeConstants::END_DATE->value => '06/06/2013',
         ],
         'daterange_plain' => [
-          DateTimeRangeConstants::START_DATE => '2012-12-31',
-          DateTimeRangeConstants::END_DATE => '2013-06-06',
+          DateTimeRangeConstants::START_DATE->value => '2012-12-31',
+          DateTimeRangeConstants::END_DATE->value => '2013-06-06',
         ],
         'daterange_custom' => [
-          DateTimeRangeConstants::START_DATE => '2012-12-31',
-          DateTimeRangeConstants::END_DATE => '2013-06-06',
+          DateTimeRangeConstants::START_DATE->value => '2012-12-31',
+          DateTimeRangeConstants::END_DATE->value => '2013-06-06',
         ],
       ],
       DateRangeItem::DATETIME_TYPE_DATETIME => [
         'daterange_default' => [
-          DateTimeRangeConstants::START_DATE => '12/31/2012 - 00:00',
-          DateTimeRangeConstants::END_DATE => '06/06/2013 - 00:00',
+          DateTimeRangeConstants::START_DATE->value => '12/31/2012 - 00:00',
+          DateTimeRangeConstants::END_DATE->value => '06/06/2013 - 00:00',
         ],
         'daterange_plain' => [
-          DateTimeRangeConstants::START_DATE => '2012-12-31T00:00:00',
-          DateTimeRangeConstants::END_DATE => '2013-06-06T00:00:00',
+          DateTimeRangeConstants::START_DATE->value => '2012-12-31T00:00:00',
+          DateTimeRangeConstants::END_DATE->value => '2013-06-06T00:00:00',
         ],
         'daterange_custom' => [
-          DateTimeRangeConstants::START_DATE => '2012-12-31T00:00:00',
-          DateTimeRangeConstants::END_DATE => '2013-06-06T00:00:00',
+          DateTimeRangeConstants::START_DATE->value => '2012-12-31T00:00:00',
+          DateTimeRangeConstants::END_DATE->value => '2013-06-06T00:00:00',
         ],
       ],
       DateRangeItem::DATETIME_TYPE_ALLDAY => [
         'daterange_default' => [
-          DateTimeRangeConstants::START_DATE => '12/31/2012',
-          DateTimeRangeConstants::END_DATE => '06/06/2013',
+          DateTimeRangeConstants::START_DATE->value => '12/31/2012',
+          DateTimeRangeConstants::END_DATE->value => '06/06/2013',
         ],
         'daterange_plain' => [
-          DateTimeRangeConstants::START_DATE => '2012-12-31',
-          DateTimeRangeConstants::END_DATE => '2013-06-06',
+          DateTimeRangeConstants::START_DATE->value => '2012-12-31',
+          DateTimeRangeConstants::END_DATE->value => '2013-06-06',
         ],
         'daterange_custom' => [
-          DateTimeRangeConstants::START_DATE => '2012-12-31',
-          DateTimeRangeConstants::END_DATE => '2013-06-06',
+          DateTimeRangeConstants::START_DATE->value => '2012-12-31',
+          DateTimeRangeConstants::END_DATE->value => '2013-06-06',
         ],
       ],
     ];
@@ -1556,9 +1556,9 @@ public function fromToSettingDataProvider() {
         // Both start and end date.
         $return[$datetime_type . '-' . $field_formatter_type . '-both'] = [
           'expected' => [
-            $dates[DateTimeRangeConstants::START_DATE] => TRUE,
+            $dates[DateTimeRangeConstants::START_DATE->value] => TRUE,
             $separator => TRUE,
-            $dates[DateTimeRangeConstants::END_DATE] => TRUE,
+            $dates[DateTimeRangeConstants::END_DATE->value] => TRUE,
           ],
           'datetime_type' => $datetime_type,
           'field_formatter_type' => $field_formatter_type,
@@ -1567,25 +1567,25 @@ public function fromToSettingDataProvider() {
         // Only start date.
         $return[$datetime_type . '-' . $field_formatter_type . '-start_date'] = [
           'expected' => [
-            $dates[DateTimeRangeConstants::START_DATE] => TRUE,
+            $dates[DateTimeRangeConstants::START_DATE->value] => TRUE,
             $separator => FALSE,
-            $dates[DateTimeRangeConstants::END_DATE] => FALSE,
+            $dates[DateTimeRangeConstants::END_DATE->value] => FALSE,
           ],
           'datetime_type' => $datetime_type,
           'field_formatter_type' => $field_formatter_type,
-          ['from_to' => DateTimeRangeConstants::START_DATE],
+          ['from_to' => DateTimeRangeConstants::START_DATE->value],
         ];
 
         // Only end date.
         $return[$datetime_type . '-' . $field_formatter_type . '-end_date'] = [
           'expected' => [
-            $dates[DateTimeRangeConstants::START_DATE] => FALSE,
+            $dates[DateTimeRangeConstants::START_DATE->value] => FALSE,
             $separator => FALSE,
-            $dates[DateTimeRangeConstants::END_DATE] => TRUE,
+            $dates[DateTimeRangeConstants::END_DATE->value] => TRUE,
           ],
           'datetime_type' => $datetime_type,
           'field_formatter_type' => $field_formatter_type,
-          ['from_to' => DateTimeRangeConstants::END_DATE],
+          ['from_to' => DateTimeRangeConstants::END_DATE->value],
         ];
       }
     }
diff --git a/core/modules/datetime_range/tests/src/FunctionalJavascript/DateRangeFieldTest.php b/core/modules/datetime_range/tests/src/FunctionalJavascript/DateRangeFieldTest.php
index 052050ba8660e2a5fffef25a7aadf24bc614ab33..c21f5451616bde13631359d3b8376bfa521a82e4 100644
--- a/core/modules/datetime_range/tests/src/FunctionalJavascript/DateRangeFieldTest.php
+++ b/core/modules/datetime_range/tests/src/FunctionalJavascript/DateRangeFieldTest.php
@@ -82,13 +82,13 @@ public function testFromToSeparatorState() {
 
     // Assert that date separator field is visible if 'from_to' is set to
     // BOTH.
-    $this->assertSession()->fieldValueEquals($from_to_locator, DateTimeRangeConstants::BOTH);
+    $this->assertSession()->fieldValueEquals($from_to_locator, DateTimeRangeConstants::BOTH->value);
     $this->assertTrue($separator->isVisible());
     // Assert that the date separator is not visible if 'from_to' is set to
     // START_DATE or END_DATE.
-    $page->selectFieldOption($from_to_locator, DateTimeRangeConstants::START_DATE);
+    $page->selectFieldOption($from_to_locator, DateTimeRangeConstants::START_DATE->value);
     $this->assertFalse($separator->isVisible());
-    $page->selectFieldOption($from_to_locator, DateTimeRangeConstants::END_DATE);
+    $page->selectFieldOption($from_to_locator, DateTimeRangeConstants::END_DATE->value);
     $this->assertFalse($separator->isVisible());
   }