On two ways to display the current date on a Web page

Source: Internet
Author: User
Tags date format insert
Date | page | show

On the Internet, you will often see the current date on some pages, such as: "Today is x year x month x day X" and so on. To display the current date of the system, generally using the scripting language VBScript or JavaScript, the two languages have their own characteristics, especially in web teaching, through the use of these two languages and contrast, can achieve better teaching results, more can achieve the role of extrapolate, are introduced respectively their design process.

  First, the use of VBScript scripting language

Displays the current date of the system in the VBScript scripting language, typically using the date and time functions provided internally:

date--Return System date

Weekday (x)--Return date x is the day of the week

Year (x)--back to date X

Month (x)--Returns the month of date X

Day (x)--Returns the date of date X

When you enter HTML editing at design time, insert the following code where you want to display the date:

  Second, the use of JavaScript scripting language

The JavaScript scripting language is used to display the current date of the system, usually using the Date object provided internally, which can be used to handle actions on dates and times. Use the following methods in the Date object to display the date:

GetDate ()--Get the current date

Getday ()--Get the current week

GetMonth ()--Get the current month

GetYear ()--Get the current year

When you enter HTML editing at design time, insert the following code where you want to display the date:

Both of these methods can display the current date of the system, they have unique characteristics, strengths. Obviously, VBScript and JavaScript scripting languages are significantly different in format, and beginners can easily confuse them, resulting in a serious format error in the program.

In web design, the use of scripting language is a major difficulty, so, in teaching, let students use the above two methods to make, let them to distinguish between the similarities and differences between the two languages, personally to understand the magical script language. This will greatly help students to use the scripting language flexibly, so as to improve their ability of language analysis, improve their interest in learning Web pages, and get better teaching results.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.