Drupal 8 block cache I created a simple block where it shows good evening or good afternoon depending on the time.

But the problem is that i have to delete the cache otherwise it will stay at good evening ...

How do i disable the cache for this specific block ?

Here is the twig page:

  {% block content %}
{{ content }}
&lt;p&gt;{{ "now"|date("d,n,Y") }}
{% if "now"|date("H") &gt;= '10' %}
 good afternoon,
{% else %}
good evening,
{% endif %}
&lt;/p&gt;
{% endblock %}
This will disable the cache.

$build['#cache']['max-age'] = 0;


Block Cache API is removed; blocks now use standard caching patterns