How to get the value of a datetime when form submitted
You can use the method getTimeStamp() to store the timestamp like this :

$form_state-&gt;getValue('timesave')-&gt;getTimeStamp();


Or you can use the format() function to store a formatting date.

$form_state-&gt;getValue('timesave')-&gt;format("Y-m-d H:i:s");