Answers.Body: <p>You can add a new filter to twig that returns an empty string if the date is null or '0000-00-00', or if not reverts to Twig's built in date filter.
  Here I've called it 'dateInclEmpty' <em>(trying to think of a better name)</em>, you can otherwise use it in the same way as the existing date filter.</p>
  
  <pre><code>$filter = function(Twig_Environment $env){
      return new Twig_SimpleFilter('dateInclEmpty', function ($date,$format,$timezone) use($env){
          if (is_null($date) || $date == '0000-00-00'){
              return "";
          }
          else {
              return twig_date_format_filter($env,$date,$format,$timezone);
          }
      });
  };
  $twig-&gt;addFilter($filter($twig));
  </code></pre>
  
  <p><em>(Thanks for the advice Lindsey, let's see if this is any better :-P)</em></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-20T15:50:00.797Z
Answers.Text: -1 Hacking the core is never a good idea :(
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-22T10:49:27.597Z
Answers.Text: I've made it as a new filter instead, hopefully less hacky
Answers.UserDisplayName: leontrolski
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-22T16:15:32.283Z
Answers.Text: Much better! :)
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-20T10:50:08.647Z
Answers.LastActivityDate: 2016-01-22T10:48:15.427Z
Answers.LastEditDate: 2016-01-22T10:48:15.427Z
Answers.UserDisplayName: leontrolski
Answers.Body: <p>For DateTime:</p>
  
  <pre><code>{{ entry.myDate =="0000-00-00 00:00:00" ? "" : entry.myDate|date('Y-m-d') }}
  </code></pre>
  
  <p>For Date :</p>
  
  <pre><code>{{ entry.myDate =="0000-00-00" ? "" : entry.myDate|date('Y-m-d') }}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-30T20:29:01.357Z
Answers.LastActivityDate: 2018-07-30T21:48:50.143Z
Answers.LastEditDate: 2018-07-30T21:48:50.143Z
Answers.UserDisplayName: Hossein Bagherzadegan
Answers.Body: <p>That happens because the <a href="http://twig.sensiolabs.org/doc/filters/date.html" rel="noreferrer"><code>date</code></a> filter returns the current date for null values / empty strings.</p>
  
  <blockquote>
    <p>If the value passed to the date filter is null, it will return the current date by default.</p>
  </blockquote>
  
  <p>To work around this, you would add a conditional.</p>
  
  <pre><code>{% if entry.myDate %}
      Date: {{ entry.myDate|date('Y-m-d') }}
  {% endif %}
  </code></pre>
  
  <p>Another way to do this is to use a <a href="http://twig.sensiolabs.org/doc/templates.html#other-operators" rel="noreferrer">ternary operator</a>.</p>
  
  <pre><code>{{ entry.myDate ? entry.myDate|date('Y-m-d') }}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-19T12:02:06.133Z
Answers.Text: for completeness `{{ entry.myDate ? entry.myDate|date('Y-m-d') : 'XYZ' }}`
Answers.UserDisplayName: caramba
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-17T11:37:33.457Z
Answers.LastActivityDate: 2015-04-17T11:37:33.457Z
Answers.UserDisplayName: carlcs
Body: <p>I have a date field, and I want it to be possible for this to be empty. How it works now is that if you don't enter a value, it takes today's date. Any suggestions?</p>
  
Tags: <datetime>
Title: Empty date field becomes today's date
ThreadText: # Empty date field becomes today's date
  
  (Asked by: username_0 on 2015-04-17)
  
  I have a date field, and I want it to be possible for this to be empty. How it works now is that if you don't enter a value, it takes today's date. Any suggestions?
  
  **Tags:** datetime
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_4 on 2015-04-17. Score: 8 | Accepted answer
  
  That happens because the [`date`](http://twig.sensiolabs.org/doc/filters/date.html) filter returns the current date for null values / empty strings.
  
  > If the value passed to the date filter is null, it will return the current date by default.
  
  To work around this, you would add a conditional.
  
  ```
  {% if entry.myDate %}
      Date: {{ entry.myDate|date('Y-m-d') }}
  {% endif %}
  
  ```
  
  Another way to do this is to use a [ternary operator](http://twig.sensiolabs.org/doc/templates.html#other-operators).
  
  ```
  {{ entry.myDate ? entry.myDate|date('Y-m-d') }}
  
  ```
  
  > **Comments:**
  > **username_5**: for completeness `{{ entry.myDate ? entry.myDate|date('Y-m-d') : 'XYZ' }}`  
  
  ---
  
  ### Answer by username_1 on 2016-01-20. Score: 2
  
  You can add a new filter to twig that returns an empty string if the date is null or '0000-00-00', or if not reverts to Twig's built in date filter.
  Here I've called it 'dateInclEmpty' *(trying to think of a better name)*, you can otherwise use it in the same way as the existing date filter.
  
  ```
  $filter = function(Twig_Environment $env){
      return new Twig_SimpleFilter('dateInclEmpty', function ($date,$format,$timezone) use($env){
          if (is_null($date) || $date == '0000-00-00'){
              return "";
          }
          else {
              return twig_date_format_filter($env,$date,$format,$timezone);
          }
      });
  };
  $twig->addFilter($filter($twig));
  
  ```
  
  *(Thanks for the advice username_2, let's see if this is any better :-P)*
  
  > **Comments:**
  > **username_2**: -1 Hacking the core is never a good idea :(  
  > **username_1**: I've made it as a new filter instead, hopefully less hacky  
  > **username_2**: Much better! :)  
  
  ---
  
  ### Answer by username_3 on 2018-07-30. Score: 1
  
  For DateTime:
  
  ```
  {{ entry.myDate =="0000-00-00 00:00:00" ? "" : entry.myDate|date('Y-m-d') }}
  
  ```
  
  For Date :
  
  ```
  {{ entry.myDate =="0000-00-00" ? "" : entry.myDate|date('Y-m-d') }}
  
  ```
  
  
  ---
  
  