Javascript - Get The Days of the Week

In this tutorial we will create a Get The Days of the Week using Javascript. JavaScript is a scripting or programming language that allows you to implement complex things on web pages. It is widely used in designing a stunning website. It is an interpreted programming language that has a capabilities of Object-Oriented. This code can be used as your calculator to any mathematical problem. So Let's do the coding...

Getting started:

This is the link for the bootstrap that i used for the layout design https://getbootstrap.com/.

The Main Interface

This code contains the interface of the application. To create this just write these block of code inside the text editor and save this as index.html.

Javascript - Get The Days of the Week



Creating the Script

This code contains the script of the application. This code will calculate and determine the days of the week. To do this just copy and write these block of codes as shown below inside the text editor and save it as script.js inside the js folder. function GetWeek(){ var date = document.getElementById('date'); if(date.value == ""){ alert("Please enter a date first!"); }else{ var months= ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; var newDate = new Date(date.value); var dates = new Array(); dates = CalculateDayOfWeek(newDate); var data ="

Days of the week

"; for(var i=0; i "+days[dates[i].getDay()]+": "+months[dates[i].getMonth()]+" "+dates[i].getDate()+", "+dates[i].getFullYear()+"
"; } document.getElementById('result').innerHTML = data; } } function CalculateDayOfWeek(date){ var days = new Array(); for (var i = 0; i There you have it we successfully created a Get The Days of the Week using Javascript. I hope that this simple tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!

Add new comment