Skip to content

Instantly share code, notes, and snippets.

@klarstil
Created September 12, 2013 10:03
Show Gist options
  • Save klarstil/6535288 to your computer and use it in GitHub Desktop.
Save klarstil/6535288 to your computer and use it in GitHub Desktop.
var randomDate = function() {
var now = new Date(),
minMonth = 1, maxMonth = now.getMonth(),
minDay = 1, maxDay = 26,
randMonth, randDay, date;
randMonth = Math.floor(Math.random() * (maxMonth - minMonth + 1) + minMonth);
randDay = Math.floor(Math.random() * (maxDay - minDay + 1) + minDay);
date = new Date(2013, randMonth, randDay);
return (date.getDate() > 9 ? '' : '0') + date.getDate() + '.' + (date.getMonth() > 9 ? '' : '0') + date.getMonth() + '.' + date.getFullYear();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment