code: function makeDateFromStringAndFormat(string, format) {
          // This array is used to make a Date, either with `new Date` or `Date.UTC`
          // We store some additional data on the array for validation
          // datePartArray[7] is true if the Date was created with `Date.UTC` and false if created with `new Date`
          // datePartArray[8] is false if the Date is invalid, and undefined if the validity is unknown.
          var datePartArray = [0, 0, 1, 0, 0, 0, 0],
              config = {
                  tzh : 0, // timezone hour offset
                  tzm : 0  // timezone minute offset
              },
              tokens = format.match(formattingTokens),
              i, parsedInput;
  
          for (i = 0; i < tokens.length; i++) {
              parsedInput = (getParseRegexForToken(tokens[i]).exec(string) || [])[0];
              if (parsedInput) {
                  string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
              }
              // don't parse if its not a known token
              if (formatTokenFunctions[tokens[i]]) {
                  addTimeToArrayFromToken(tokens[i], parsedInput, datePartArray, config);
              }
          }
          // handle am pm
          if (config.isPm && datePartArray[3] < 12) {
              datePartArray[3] += 12;
          }
          // if is 12 am, change hours to 0
          if (config.isPm === false && datePartArray[3] === 12) {
              datePartArray[3] = 0;
          }
          // return
          return dateFromArray(datePartArray, config.isUTC, config.tzh, config.tzm);
      }
docs: date from string and format string