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 - coursesweb.net/javascript/
// 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>';
}
--></script>
<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">
  <tr>
    <td colspan="3" style="font-size:16px;">Select the date:</td>
  </tr>
  <tr>
    <td>Day: 
      <select name="sdays" size="1">
<script type="text/javascript"><!--
  for(var j=1;j<32;j++)
  document.write("<option value="+j+">"+j+"</option>");
--></script>
      </select></td>
    <td>Month: 
<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>");
--></script>
     </select></td>
    <td>Year: 
      <select name="birthyear" size="1">
<script type="text/javascript"><!--
  for(var k=startyear;k<endyear;k++)
  document.write("<option value="+k+">"+k+"</option>");
--></script>
    </select></td>
  </tr>
  </table>
  </div><div>
<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">
  </div>
</form>

Daily Test with Code Example

HTML
CSS
JavaScript
PHP-MySQL
Which tag renders as emphasized text, displaying the text oblique?
<strong> <pre> <em>
<p>Web development courses: <em>CoursesWeb.net</em></p>
Which CSS property defines the space between the element border and its content?
margin padding position
h3 {
  padding: 2px 0.2em;
}
Click on the method which returns the first element that matches a specified group of selectors.
getElementsByName() querySelector() querySelectorAll()
// gets first Div with class="cls", and shows its content
var elm = document.querySelector("div.cls");
alert(elm.innerHTML);
Indicate the PHP variable that contains data from a form sent with method="post".
$_SESSION $_GET $_POST
if(isset($_POST["field"])) {
  echo $_POST["field"];
}
Find the Day of the Week

Last accessed pages

  1. Using openssl_encrypt and openssl_decrypt in PHP (1312)
  2. CSS Box Model (768)
  3. PHP MySQL - WHERE and LIKE (29547)
  4. Voting Poll System script PHP-AJAX (8776)
  5. Update and Delete MySQL data with data from Form (1261)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (458)
  2. CSS cursor property - Custom Cursors (67)
  3. Read Excel file data in PHP - PhpExcelReader (46)
  4. PHP-MySQL free course, online tutorials PHP MySQL code (44)
  5. PHP Unzipper - Extract Zip, Rar Archives (41)