Answers for "write a function that converts user entered date formatted as m/d/yyyy"

1

write a function that converts user entered date formatted as m/d/yyyy

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"));
Posted by: Guest on September-30-2020

Code answers related to "write a function that converts user entered date formatted as m/d/yyyy"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language