Recommended: How to generate pictures from digital images in web pages Save the following code as myimg.asp, and insert imgsrc=myimg.asp?tel=010-0000000 at the position where the number to be displayed (such as QQ number, etc.). % CallCom_CreatValidCode(Request.QueryString(tel)) PublicSubCom_CreatValidCode(pTel) '----------禁止缓存Response.Expires=0 Response.
In ASP, we provide special date addition and subtraction functions.1. Add dates
DateAdd function
Returns the date when the specified time interval has been added.
DateAdd(interval,number,date)
The syntax of the DateAdd function has the following parameters
(1) Must-have options for interval. A string expression that indicates the time interval to be added. For values, see the Settings section.
(2) Number required. Numeric expression, indicating the number of time intervals to be added. Numeric expressions can be positive (get future dates) or negative (get past dates).
(3) A required date option. Variant or text that represents the date to add interval.
illustrate
The DateAdd function can be used to add or subtract the specified time interval from the date. For example, DateAdd can be used to calculate the date 30 days from the same day or to calculate the time 45 minutes from the present day. To add a time interval in days to date, you can use the number of days (y), days (d) of one year, or the number of days (w) of a week.
The DateAdd function does not return an invalid date. The following example adds one month to January 31, 2019:
NewDate=DateAdd(m,1,31-Jan-95)
In this example, DateAdd returns February 28, 95, instead of February 31, 95. If date is January 31, 2019, it returns February 29, 2019, because 1996 is a leap year.
If the calculated date is before 100 AD, an error will be generated.
If number is not a Long value, rounded to the closest integer before calculation.
2. Date subtraction
DateDiff function
Returns the time interval between two dates.
DateDiff(interval,date1,date2[,firstdayofweek[,firstweekofyear]])
The syntax of the DateDiff function has the following parameters:
(1) Must-have options for interval. A string expression that represents the time interval used to calculate date1 and date2. For values, see the Settings section.
(2) The required options for date1 and date2. Date expression. Two dates used for calculation.
(3) First day of week is optional. Specifies the constant for the first day of the week. If not specified, the default is Sunday. For values, see the Settings section.
(4) Firstweekofyear is optional. Specify the constant for the first week of the year. If not specified, the default is the week on January 1st. For values, see the Settings section.
illustrate
The DateDiff function is used to determine the number of specified time intervals that exist between two dates. For example, you can use DateDiff to calculate the number of days when the two dates differ, or the number of weeks between the same day and the last day of the year.
To calculate the number of days between date1 and date2, you can use the number of days (y) or days (d) of one year. When interval is the number of days of the week (w), DateDiff returns the number of days of the week between the two dates. If date1 is Monday, DateDiff calculates the number of Mondays before date2. This result contains date2 and not date1. If the interval is week (ww), the DateDiff function returns the number of weeks between two dates in the calendar table. The function calculates the number of Sundays between date1 and date2. If date2 is Sunday, DateDiff will calculate date2, but even if date1 is Sunday, date1 will not be calculated.
If date1 is later than date2, the DateDiff function returns a negative number.
The firstdayofweek parameter will have an impact on the calculation using w and ww interval symbols.
If date1 or date2 is a date text, the specified year becomes a fixed part of the date. But if date1 or date2 is included in quotes () and the year is omitted, the current year will be inserted every time the date1 or date2 expression is calculated in the code. This allows you to write program code for different years.
When interval is year (yyyy), compare December 31 and January 1 of the following year. Although it is actually only one day apart, DateDiff returns 1 to indicate one year difference.
Share: How to prevent illegal link theft of this site At present, there are many illegal links to theft of web pages and files on other websites. The following method is to prevent links using asp code. The main idea is to use Request.ServerVariables to collect HTTP_REFERRER, and then determine whether the link comes from outside based on the value of this variable to prevent illegal links. First, we need to quote the image as follows: imgsrc=