📄 ch12-04-02.aspx
字号:
<Html>
<Head>
<Title>Ch12-04-02.aspx 日期与时间的运算</Title>
</Head>
<Body>
<H2>System.DateTime类-日期与时间的运算</H2>
<%
Dim NowTime As Date = DateTime.Now
Response.Write("今天日期与时间:" & NowTime.ToString() & "<BR>")
Response.Write("今年是否为闰年:" & NowTime.IsLeapYear(NowTime.Year) & "<BR>")
' 日期运算
Response.Write("年份运算,去年为:" & NowTime.AddYears(-1).ToString() & "<BR>")
Response.Write("年份运算,明年为:" & NowTime.AddYears(1).ToString() & "<BR>")
Response.Write("月份运算,上个月是:" & NowTime.AddMonths(-1).ToString() & "<BR>")
Response.Write("月份运算,下个月是:" & NowTime.AddMonths(1).ToString() & "<BR>")
Response.Write("日期运算,昨天:" & NowTime.AddDays(-1).ToString() & "<BR>")
Response.Write("日期运算,明天:" & NowTime.AddDays(1).ToString() & "<BR>")
' 时间运算
Response.Write("时间运算,一个小时之后:" & NowTime.AddHours(1).ToString() & "<BR>")
Response.Write("时间运算,五个小时之前:" & NowTime.AddHours(-5).ToString() & "<BR>")
Response.Write("时间运算,一分钟之后:" & NowTime.AddMinutes(1).ToString() & "<BR>")
Response.Write("时间运算,五分钟之前:" & NowTime.AddMinutes(-5).ToString() & "<BR>")
%>
</Body>
</Html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -