Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions DateAndTime/myDayFunction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/* An old script I wrote back in 2012 - I'll 'improve' it later. */
function myDayFunction() {

var d = new Date();
var date = d.getDate();
var day = d.getDay();
var month = d.getMonth();
var year = d.getFullYear();

/* Append the correct date type */
if (date==1 || date==21 || date==31) {
date = date + "st";
}
else if (date==2 || date==22) {
date = date + "nd";
}
else if (date==3 || date==23) {
date = date + "rd";
}
else if (date > 3) {
date = date + "th";
}

/* Change the numeric date value to the name */
switch (day) {
case 0:
day = "Sunday";
break;

case 1:
day = "Monday";
break;

case 2:
day = "Tuesday";
break;

case 3:
day = "Wednesday";
break;

case 4:
day = "Thursday";
break;

case 5:
day = "Friday";
break;

case 6:
day = "Saturday";
break;

}

/* Change the numeric month value to the name */
switch (month) {
case 0:
month = "January";
break;

case 1:
month = "February";
break;

case 2:
month = "March";
break;

case 3:
month = "April";
break;

case 4:
month = "May ";
break;

case 5:
month = "June";
break;

case 6:
month = "July";
break;

case 7:
month = "August";
break;

case 8:
month = "September";
break;

case 9:
month = "October";
break;

case 10:
month = "November";
break;

case 11:
month = "December";
break;
}

/* Write everything out */
document.write("<div class='datetxt'>");
document.write(day + ", " + date + " " + month + ", " + year);
document.write("</div>");

}
12 changes: 12 additions & 0 deletions DateAndTime/myDayFunctionExample.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<head>
<title>My Day Function Example</title>
<script type="text/javascript" src="myDayFunction.js"></script>
<script type="text/javascript" src="myYearAndDate.js"></script>
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body>
<div><script type="text/javascript">myDayFunction()</script></div>
<div><script type="text/javascript">myYearAndDate()</script></div>
</body>
13 changes: 13 additions & 0 deletions DateAndTime/myYearAndDate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* An old script I wrote back in 2012 - I'll 'improve' it later. */

function myYearAndDate() {

var d = new Date();
var year = d.getFullYear();

/* Write everything out */
document.write("<div style='footertxt'>");
document.write("Write a &copy;" + year + " statement that never goes out of date.<br>");
document.write("</div>");

}
5 changes: 5 additions & 0 deletions DateAndTime/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* main styles */
body { padding:0; margin:10; vertical-align:top; background:#ffffff; font-family:Tahoma;}

.datetxt {color:#5A0F0F; font-size:20px;}
.footertxt {font-size:10px;}