Random Day of Week Calculator


Random Date generator

References
  1. Link
  2. Link

Here is the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<html>
<body>
<h4 id="toc-random-date-generator1">Random Date generator</h4>
<script type="text/javascript">
 
var rmo=Math.floor(Math.random()*12)
var rday=Math.floor(Math.random()*30)
//function to get random number upto m
function randomXToY(minVal,maxVal,floatVal)
{
  var randVal = minVal+(Math.random()*(maxVal-minVal));
  return typeof floatVal=='undefined'?Math.round(randVal):randVal.toFixed(floatVal);
}
var ryr= randomXToY(1600, 2200)
var d=new Date();
//I have no idea why, but the months are (0=jan,1=feb, 11=dec)
d.setFullYear (ryr,rmo, rday);
 
var weekday=new Array(7);
weekday[0]="Sunday";
weekday[1]="Monday";
weekday[2]="Tuesday";
weekday[3]="Wednesday";
weekday[4]="Thursday";
weekday[5]="Friday";
weekday[6]="Saturday";
rmo=rmo +1;
document.write("Random Date is " + rmo + "/" + rday +  "/" + ryr );
document.write("<br/><p>");
document.write("That date fell on a ? ");
document.write("<br/><p>");
 
 
</script>
<a href="javascript:onClick=alert(weekday[d.getDay()])">Answer</a>
<p>
<a href="javascript:onClick=location.reload(true)">Refresh this page</a>
<p>	
<h5 id="toc-references1">References</h5>
<ol>
<li><a href="http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_date_weekday_utc">Link</a></li>
<li><a href="http://www.theworldofstuff.com/other/day.html">Link</a></li>
</ol>
</body>
</html>