Skip to content

Instantly share code, notes, and snippets.

@chmanie
Created March 18, 2014 22:35
Show Gist options
  • Save chmanie/9631292 to your computer and use it in GitHub Desktop.
Save chmanie/9631292 to your computer and use it in GitHub Desktop.
Parser for german date format
function parseGermanDate(val) {
var parsed = val.match(/^(\d{1,2})\.\s?(\d{1,2}).\s?(\d{2,4})$/);
if (parsed) {
var year = (parsed[3].length === 2) ? parseInt('20' + parsed[3], 10) : parseInt(parsed[3], 10);
var month = parseInt(parsed[2], 10) - 1;
var day = parseInt(parsed[1]);
return new Date(year, month, day);
}
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment