Dates can be used for many things. They might be used on a forum to inform users when a topic was posted, or to inform a user when he/she registered an account. It can also be used to display a message depending on the date.
Below is the basic format of the date function:
Code :
So if the date today was the 24th October, 2009 the output would be:
Output:2009/10/24
As you can see it displays the date. The letters used within the brackets define what format the date will appear in, the forward slashes merely separate the values to display the date more clearly. There are many available formats for the date that are extremely flexible, for a full list of possible formats click here and scroll down to the table.
I'll now use the date format combined with a switch statement to show an example of how the date function can be used:
Code :
So if today was a saturday the output would be:
Output:Hope you're having a good weekend!
Although the code is fairly useless in terms of using it on a site, it does show you how the date function can be used. That concludes this tutorial, but in the next tutorial we will learn how to include other pages into one webpage!
To post comments you must sign in to your account below!
If you do not currently have an account click here to create one now!