Set timestamp field default value empty I have created field type "Timestamp" in my Drupal 8 node. Field is not required. In field settings default value, there is HTML 5 datetime picker, in which you can select default date/time or leave values as on picture:



But the Drupal behavior seem to be little bit strange - when you select default date, this value is set on node save (this is correct). When you leave field blank (values as on picture) it saves field with time of form submission (it is stated in field comment, so it is not a bug)... But how to disable default value, when you just want to leave field blank as it is possible with all other fields (e.g. text, number, ...)? I do not see any settings for this in this field configuration. Also this is not logical, beucase when you leave other fields blank, they are really blank. When you leave this field type blank, it still saves value (some additional checkbox will be more logical)?

Thanks
There is backstory to this that is a little complicated.

The Timestamp field type was added back into Drupal 8.2.0 core as a "UI Field".  The field type had always been there, just as a behind-the-scenes field, and used as the base field for CreatedItem and ChangedItem for entity timestamps (which are both non-UI field types).

If this field is rendered out on with the proper widget on the edit page (see bug), then you end up using  TimestampDatetimeWidget.  This widget has a ::massageFormValues() method, which enforces the current time being used (at save) as the field value if the element is empty.

So, the behavior you are seeing is by-design.  The widget was initially intended for entity edit pages, where created and changed timestamps never have empty values after the entity is saved.  When this field was added as a UI field, it inherited the widget and its behavior.

If you really want a timestamp and don't want this behavior, you need to make a custom module and make your own widget.  You should just be able to copy TimestampDatetimeWidget into the module, rename it, update the annotation, and update the ::massageFormValues() method:


remove the else branch containing $date = new DrupalDateTime(); - this won't set the default datetime
handle unset $date variable, example: $item['value'] = !empty($date) ? $date-&gt;getTimestamp() : NULL;


That should allow you to have empty timestamps.

Personally, I would not use Timestamp fields, though.  I would use Date fields, which can have empty values or default values, and better widgets and formatters in general.