how to get the date value in drupal 8 On submitting a form getting error as

Error: Call to a member function format() on null.

Here is the function:

public function submitForm(array &amp;$form, FormStateInterface $form_state) { 
  $exp_date = $form_state-&gt;getValue('expire_date')-&gt;format('H:i:s'); 
}
As mentioned by @awm in the comment you have to use the DateFormatter service. But the format() method needs a timestamp so you can use strtotime() to parse the value:

$exp_date = \Drupal::service('date.formatter')
  -&gt;format(strtotime($form_state-&gt;getValue('expire_date')), 'H:i:s');