Check out example codes for "write a function that converts user entered date formatted as m/d/yyyy". It will help you in understanding the concepts better.

Code Example 1

function formatDate(userDate) 
{
  var parts = userDate.split('/');
  if (parts[0].length == 1) parts[0] = '0' + parts[0];
  if (parts[1].length == 1) parts[1] = '0' + parts[1];
  return parts[2] + parts[0] + parts[1];
}

console.log(formatDate("12/10/2017"));

Learn ReactJs, React Native from akashmittal.com