Javascript (Mootools) random date generator

I've needed a random date generator between two dates. This has been easy with Mootools. Both dates are first converted to unix timestamp format (# of seconds after 1.1.1970), then a random number between the two unix times is generated and converted back to date.



function randomDate(date1, date2) {
   var minD = new Date().parse(date1).format('%s');
   var maxD = new Date().parse(date2).format('%s');
   var random = Number.random(parseInt(minD), parseInt(maxD));
   var randomDate = new Date().parse(random+"000").format('db'); 
}

Which can be called

var randomDateTmp = randomDate('1999-06-08 16:34:52', new Date()); 

Set the format accordingly to http://mootools.net/docs/more/Types/Date#Date:format

This can be easily accomplished in other programming languages.