Javascript Course

With this script you can find the corresponding day of the week of any date between 1900 and 2050.
You can test this script in this example.
Select the date:
Day: Month: Year:
Here will be displayed the selected date, and the name of the day.

• To add this script in a web page, include the following code in the location where you want to display the form for this script:
<script type="text/javascript"><!--
// Get the day of the week -
// array with the name of the month
var month = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

// array with the name of the days
var weekday = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");

var startyear = "1900";      // first year in select list
var endyear = "2050";      // last year in select list

// adds in #weekday the selected date, and the name of the day
function getWeekDay() {
  // get the values of the selected date
  var month = document.daydate.smonths.options[document.daydate.smonths.selectedIndex].value;
  var day = document.daydate.sdays.options[document.daydate.sdays.selectedIndex].value;
  var year = document.daydate.birthyear.options[document.daydate.birthyear.selectedIndex].value;

  var obdate = new Date(year,month,day);           // object for selected date
  var nday = obdate.getDay();                     // the number of the day in the week

  document.getElementById('gweekday').innerHTML = 'The name of the day in: <i>'+day+'-'+(month*1 +1)+'-'+year+'</i> is: <b>'+ weekday[nday]+'</b>';
<form name="daydate" style="text-align:center;" action="" method="post">
  <div align="center"><table style="text-align:center; background:#fbfbfe; padding:2px;" border="2" cellpadding="0" cellspacing="0">
    <td colspan="3" style="font-size:16px;">Select the date:</td>
      <select name="sdays" size="1">
<script type="text/javascript"><!--
  for(var j=1;j<32;j++)
  document.write("<option value="+j+">"+j+"</option>");
<select name="smonths" size="1">
<script type="text/javascript"><!--
  for(var i=0;i<month.length;i++)
  document.write("<option value="+i+">"+month[i]+"</option>");
      <select name="birthyear" size="1">
<script type="text/javascript"><!--
  for(var k=startyear;k<endyear;k++)
  document.write("<option value="+k+">"+k+"</option>");
<div id="gweekday">Here will be displayed the selected date, and the name of the day.</div>
    <input value="Get the day" onclick="getWeekDay()" type="button">

Daily Test with Code Example

Which attribute is used in <a> tag for the address of the link?
src href rel
<a href="" title=""></a>
Which CSS property sets the type of the text font?
font-family text-decoration font-size
h2 {
What instruction selects all the <div> tags with class="cls"?
querySelector("div.cls") getElementsByTagName("div") querySelectorAll("div.cls")
var elm_list = document.querySelectorAll("div.cls");
var nr_elms = elm_list.length;       // number of selected items
Indicate the function that can be used to get the sum of values in an array.
array_sum() array_diff() array_shift()
$arr =[1, 2, 3, 4);
$arr_sum = array_sum($arr);
echo $arr_sum;       // 10
Find the Day of the Week

Last accessed pages

  1. PHP MySQL - WHERE and LIKE (25667)
  2. Get Lower, Higher and Closest Number in JavaScript (2313)
  3. Follow the mouse cursor with a DIV inside a Parent (5649)
  4. PHP getElementById and getElementsByTagName (42303)
  5. Select in MySQL, Output results in HTML Table (15863)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (811)
  2. SHA256 Encrypt hash in JavaScript (733)
  3. Read Excel file data in PHP - PhpExcelReader (689)
  4. Create simple Website with PHP (688)
  5. PHP Unzipper - Extract Zip, Rar Archives (683)