code: function toDate(input, format) {
    format = format || [ "MM/DD/YYYY", "M/D/YYYY" ];
    input = moment(input, format, true);
  
    if (input.isValid()) {
      return input.startOf("day").toDate();
    }
    else {
      return null;
    }
  }
docs: To date