Display the current date on the web page

xiaoxiao2021-04-09  346

When online, you often see the current date on some web pages, such as: "Today is x-year × month × ×". In order to display the current date of the system, the scripting language Vbscript or JavaScript is generally used, and the two languages ​​have their own characteristics. In terms of web teaching, through the application and comparison of these two languages, it can achieve better teaching effects. The role of reaching a non-three is now introduced their design process.

First, use VBScript scripting language

Use the VBScript scripting language to display the current date of the system, usually use the date and time function provided inside:

Date - return system date

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

Year (x) - return date x year

Month (x) - Return the month of the date x

Day (x) - return date x date

Enter the HTML editing method when designing, insert the following code when you need to display the date:

Second, use JavaScript scripting language

Use the JavaScript scripting language to display the current date of the system, usually use the DATE objects provided inside, which can be used to handle the operations of the date and time. Display the date with the following methods in the Date object:

Getdate () - Get the current date

Getday () - Get the current week

GetMonth () - Get the current month

GetYear () - Getting the current year

Enter the HTML editing method when designing, insert the following code when you need to display the date:

The above two methods can display the current date of the system, and they have their own characteristics and have their own strengths. Obviously, VBScript and JavaScript scripting languages ​​have obvious differences in formats, and beginners can easily confuse them, resulting in serious errors in the format.

In web design, the use of scripting languages ​​is a difficult point. Therefore, in teaching, students will use the above two ways to make them, let them distinguish between two languages, personally understand, understand scripting languages The wonderful. This will have a great help to students' flexible use of scripting languages, thus improving their language analysis, and improving their interest in learning web pages, and further teaching results.

转载请注明原文地址:https://www.9cbs.com/read-133153.html

New Post(0)