Skip to content

Instantly share code, notes, and snippets.

@srkama
Created February 11, 2016 16:30
Show Gist options
  • Select an option

  • Save srkama/e54e525c947f64625422 to your computer and use it in GitHub Desktop.

Select an option

Save srkama/e54e525c947f64625422 to your computer and use it in GitHub Desktop.
function to get the day as string for given date in string, expexted format is MM/DD/YYYY
function findDay(myDate) {
var dayStrArray = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
var pattern = /(\d{2})\/(\d{2})\/(\d{4})/;
var dt = new Date(myDate.replace(pattern,'$3-$1-$2'));
console.log(dayStrArray[dt.getDay()]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment