Hello. Today is:
And the time is now (according to your computer):
We can get the day from the date object as follows:
//as no date has been entered, then it is taken as today.
//today is just a variable and is not a keyword!
Because today is the result is
This isn't very interesting because no one is going to be impressed by being answered with a number to 'What's the day today?'.Human beings need to be told the day's name.
So myDays, for example, is "Tueday".
The jsEditor can create arrays from a list of elements. This can be a great time saver, and so you can make large arrays easily. You can order the jsEditor online and download the full version immediately, so in a few minutes you could be using it to help you learn and develop scripts. You will also be supporting this site.
We can get today's day as follows:
The result is which is today!
This is much easier than teaching people to say, "See you on 3, then". "No, I'm busy on 3, can we make it 5?" When they are busy on Wednesday but can make Friday!
Consider the following example:
|Enter a date (use the same format as the example):|
In this case, we use a Date object with the date 25 December, 2000. (The format is important). In the same way as before, we get the day (getDay()) for this particular date. If you enter another date, then you can find out which day that is. When you click on the button, the following code activates:
<form name="form1" id="form1" method="post" action="" enctype="text/plain">
<input type="text" name="textDate" id="textDate" value="25 December, 2000" size="25" maxlength="25" />
<input type="button" value="Get day of week" onclick="getTheDay(this.form.textDate)" />
Day of week appears here
<input type="text" name="textDay" VALUE size="25" maxlength="25" />
The only thing new here is the use of eval():
We need the date with quotes around it, but, as it appears in the box, it does not have any. So we add the quotes. But this makes a mere string, and we want a Date object. So we use eval() to make the changes.
Now we know how to extract the days from a date, we will find extracting the Months much easier.
And for some programming for your brain: check out New Life Course