function getRandomDate(from, to) {The Code above not tested yet, no guarantee it's runnable...
if (!from) {
from = new Date(1900, 0, 1).getTime();
} else {
from = from.getTime();
}
if (!to) {
to = new Date(2100, 0, 1).getTime();
} else {
to = to.getTime();
}
return new Date(from + Math.random() * (to - from));
}
Showing posts with label date. Show all posts
Showing posts with label date. Show all posts
Monday, June 28, 2010
How to generate a random date between two known dates in javascript?
Subscribe to:
Posts (Atom)
