diff --git a/core/modules/system/src/Tests/Form/DatetimeTest.php b/core/modules/system/src/Tests/Form/DatetimeTest.php
new file mode 100644
index 0000000..782f361
--- /dev/null
+++ b/core/modules/system/src/Tests/Form/DatetimeTest.php
@@ -0,0 +1,54 @@
+<?php
+
+namespace Drupal\system\Tests\Form;
+
+use Drupal\Component\Serialization\Json;
+use Drupal\simpletest\WebTestBase;
+
+/**
+ * Tests the form API datetime element.
+ *
+ * @group Form
+ */
+class DatetimeTest extends WebTestBase {
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = ['form_test'];
+
+  protected $profile = 'testing';
+
+  /**
+   * Tests #type 'datetime' field mix/max attributes.
+   */
+  function testFormDatetimeMinMax() {
+    // Test min/max on empty form.
+    $this->drupalGet('form-test/datetime');
+    $this->assertFieldByXPath('//div[@id="edit-datetime"]//input[@type="date" and @min="1900-01-01" and @max="2050-12-31"]', '', 'Found input[@type="date" and @min="1900-01-01" and @max="2050-12-31"]');
+
+    // Post values w/in 1900-2050 and check min/max.
+    $edit = [
+      'datetime[date]' => '2016-12-31',
+      'datetime[time]' => '15:16:17',
+    ];
+    $this->drupalPostForm(NULL, $edit, 'Submit');
+    $this->assertFieldByXPath('//div[@id="edit-datetime"]//input[@type="date" and @min="1900-01-01" and @max="2050-12-31"]', '2016-12-31', 'Found input[@type="date" and @min="1900-01-01" and @max="2050-12-31"]');
+
+    // Post values outside 1900-2050 and check min/max.
+    $edit = [
+      'datetime[date]' => '1776-07-14',
+      'datetime[time]' => '01:02:03',
+    ];
+
+    // OK, these are the default values.
+    $this->drupalPostForm(NULL, $edit, 'Submit');
+    $this->assertFieldByXPath('//div[@id="edit-datetime"]//input[@type="date" and @min="1900-01-01" and @max="2050-12-31"]', '1776-07-14', 'Found input[@type="date" and @min="1900-01-01" and @max="2050-12-31"]');
+
+    // This makes no sense.
+    $this->assertFieldByXPath('//div[@id="edit-datetime"]//input[@type="date" and @min="1776-01-01" and @max="2050-12-31"]', '1776-07-14', 'Found input[@type="date" and @min="1776-01-01" and @max="2050-12-31"]');
+  }
+
+}
diff --git a/core/modules/system/tests/modules/form_test/form_test.routing.yml b/core/modules/system/tests/modules/form_test/form_test.routing.yml
index 2250a0b..cd34bf9 100644
--- a/core/modules/system/tests/modules/form_test/form_test.routing.yml
+++ b/core/modules/system/tests/modules/form_test/form_test.routing.yml
@@ -489,3 +489,11 @@ form_test.get_form:
     _form: '\Drupal\form_test\Form\FormTestGetForm'
   requirements:
     _access: 'TRUE'
+
+form_test.datetime:
+  path: '/form-test/datetime'
+  defaults:
+    _form: '\Drupal\form_test\Form\FormTestDatetimeForm'
+    _title: 'Datetime fields'
+  requirements:
+    _access: 'TRUE'
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestDatetimeForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestDatetimeForm.php
new file mode 100644
index 0000000..cb8db80
--- /dev/null
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestDatetimeForm.php
@@ -0,0 +1,53 @@
+<?php
+
+namespace Drupal\form_test\Form;
+
+use Drupal\Core\Form\FormBase;
+use Drupal\Core\Form\FormStateInterface;
+
+/**
+ * Form constructor for testing #type 'email' elements.
+ */
+class FormTestDatetimeForm extends FormBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getFormId() {
+    return 'form_test_datetime';
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildForm(array $form, FormStateInterface $form_state) {
+    $form['datetime'] = [
+      '#type' => 'datetime',
+      '#default_value' => NULL,
+      '#date_increment' => 1,
+      '#date_timezone' => drupal_get_user_timezone(),
+      '#required' => TRUE,
+      '#date_date_format' => 'Y-m-d',
+      '#date_date_element' => 'date',
+      '#date_date_callbacks' => [],
+      '#date_time_format' => 'H-i-s',
+      '#date_time_element' => 'time',
+      '#date_time_callbacks' => [],
+    ];
+
+    $form['submit'] = [
+      '#type' => 'submit',
+      '#value' => 'Submit',
+    ];
+
+    return $form;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function submitForm(array &$form, FormStateInterface $form_state) {
+    $form_state->setRebuild();
+  }
+
+}
