title: how to insert an empty value in mysql date type field?
body: <p>How to insert a NULL or empty value in a mysql date type field (NULL = yes).</p>
  
  <p>If I try to insert an empty value it inserts 0000-00-00 but I want to keep it empty or NULL.</p>
  
  <p>Thanks for help.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Please see that I have set default value as NULL</p>
  
  <pre><code>  `payment_due_on` date DEFAULT NULL,
  </code></pre>
  
  <p>Ok OKies</p>
  
  <p>I have got it working now</p>
  
  <pre><code>function get_mysqlDate($date, $delimiter='/') {
      if(check_empty($date)) {
          return 'NULL';
      }
      list($d, $m, $y) = explode($delimiter, $date);
      //$datetime = strtotime($date);
      return "'".date('Y-m-d', mktime(0,0,0,$m, $d, $y))."'";
  }
  
  
  
  
  "... SET mydate = ".get_mysqldate($_POST['mydate'])." ...."
  </code></pre>
  
  <p>Cheers</p>