Date Object in Javascript

Language

In this project, you will learn about date objects in javascript. The Date object is used to work with date and time. And this is the default functional key.
  1. var date = new Date();
The following are the Date Objects method. We will work only with the date.
  1. var month = date.getMonth();
Returns the month from 0 to 11.
  1. var day = date.getDate();
It will return the day of the month.
  1. var year = date.getFullYear();
It returns the 4 digit year. After the get word of the date object is always a capital letter or else it will not work. Now, let's get the day of the week.
  1. var getday = date.getDay();
This will return the number from 0 which represents Sunday and 1 is Monday, so on. In order for us to get the name of the weekday, we have put them in an array.
  1. var weekday = new Array(7);
  2. weekday[0] = "Sunday";
  3. weekday[1] = "Monday";
  4. weekday[2] = "Tuesday";
  5. weekday[3] = "Wednesday";
  6. weekday[4] = "Thursday";
  7. weekday[5] = "Friday";
  8. weekday[6] = "Saturday";
  9. var getday = weekday[date.getDay()];
Very simple javascript code. Hope you learn from this.

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Add new comment