![]() |
Start | Time | IF | Date Object | Arrays | Avoid the work | Hide email | Random | Intigrate HTML | Test |
![]() |
The Date Object Explained The Date Object is quite complex and holds a lot of data. Here are some of the things it will do for you. Once you have picked up the data from the computer
Normally you will be assigning a variable with a value but you can simply print out the answer on a page if you wish. We already used the Year so with no further ado we could write the answer to a page like this.
Or what they possibly don't know I obviously used a tiny bit more than printing right on the page to get such things as day and month names but we will get into that later. For reasons you will see later I will use variables to keep track and possibly change the data we get from the Date Object. Here are the parameters I used to print out the above statements each set to its own variable
From this you can see that we can print out the date and time in numbers like this.
If you don't like the 24 hour clock it is a simple matter to change it using a couple of 'if' statements. In case we need the 24 hour clock we will make a new variable called ' hr ' equal to ' h ' and change it instead If 'hr' is greater than 12 we need to subtract 12 from it or if it is 0 it should be 12.
Also the minutes if less than ten will not have a leading zero so another if statement will fix that but this would normally just be done in the print statement like this.
Next : Arrays Home |