- 注册时间
- 2006-6-3
- 最后登录
- 2007-12-11
- 阅读权限
- 20
- 积分
- 59
- 精华
- 0
- 帖子
- 59

- 性别
- 保密
- 听众数
- 0
- 买家信用
 - 卖家信用
 - 在线时间
- 0 小时
- 相册
- 0
|
|
[vscript]@#Uses the Timespan method to subtract a certain number of days<br>Function Date1()<br> Dim NewTime as DateTime<br> NewTime = DateTime.Now.Subtract( New TimeSpan(7, 0, 0, 0) )<br> NewTime = NewTime.Format("MM/dd/yyyy", DateTimeFormatInfo)<br> response.write(NewTime)<br>End Function<br><br>@#Uses the AddDays method to subtract X number of days<br>Public Function Date2()<br> Dim NewTime as DateTime<br> NewTime = DateTime.Now.AddDays(-7)<br> Dim s as string = NewTime<br> return s<br>End Function<br><br>@#Thanks to Paul Czywczynski for this idea<br>@#This probably (In My opinion) Offers the most flexibility found so far<br>@#Change where the MM/dd/yyyy to whatever<br>@#response.write(System.String.Format("{0:d}",NewTime))<br>@#would return just the name of the Day<br>Function Date3()<br> Dim NewTime as DateTime = now.addDays(-7) <br> response.write(System.String.Format("{0:MM/dd/yyyy}",NewTime))<br>End Function<br><br><br>Function Date4()<br>Dim NewTime as DateTime<br> NewTime = now.addDays(-7) <br> return NewTime.ToString()<br>End Function <br><br>@#Uses the toLongTimeString method<br>Public Function Date5()<br> Dim NewTime as DateTime<br> NewTime = Now()<br> return newtime.toLongTimeString()<br>End Function<br><br>@#Uses the toShortTimeString method<br>Public Function Date6()<br> Dim NewTime as DateTime<br> NewTime = Now()<br> return newtime.toShortTimeString()<br>End Function<br><br>@#Uses the toLongDateString method<br>Public Function Date7()<br> Dim NewTime as DateTime<br> NewTime = Now()<br> return newtime.toLongDateString()<br>End Function<br><br>@#Uses the toShortDateString method<br>Public Function Date8()<br> Dim NewTime as DateTime<br> NewTime = Now()<br> return newtime.toShortDatestring()<br>End Function<br><br>@#Uses FormatDateTime function General format<br>Function Date9()<br> Dim NewTime as DateTime<br> NewTime = DateTime.Now.Subtract( New TimeSpan(7, 0, 0, 0) )<br> return formatdatetime(NewTime, 0)<br>End Function<br><br>@#Uses FormatDateTime function LongDate format<br>Function Date10()<br> Dim NewTime as DateTime<br> NewTime = DateTime.Now.Subtract( New TimeSpan(7, 0, 0, 0) )<br> return formatdatetime(NewTime, 1)<br>End Function<br><br>@#Uses FormatDateTime function ShortDate format<br>Function Date11()<br> Dim NewTime as DateTime<br> NewTime = DateTime.Now.Subtract( New TimeSpan(7, 0, 0, 0) )<br> return formatdatetime(NewTime, 2)<br>End Function<br><br>@#Uses FormatDateTime function LongTime format<br>Function Date12()<br> Dim NewTime as DateTime<br> NewTime = DateTime.Now.Subtract( New TimeSpan(7, 0, 0, 0) )<br> return formatdatetime(NewTime, 3)<br>End Function<br><br>@#Uses FormatDateTime function ShortTime format<br>Function Date13()<br> Dim NewTime as DateTime<br> NewTime = DateTime.Now.Subtract( New TimeSpan(7, 0, 0, 0) )<br> return formatdatetime(NewTime, 4)<br>End Function<br><br>@#Bring Back just the name of the Day<br>Function Date14()<br> Dim NewTime as DateTime = now.addDays(-7) <br> dim s as string<br> s = (System.String.Format("{0:dddd}",NewTime))<br> Return s<br>End Function<br><br>@#Returns the Integer of what day of week<br>Function Date15()<br> Dim MyDate as DateTime<br> Dim MyWeekDay as Integer<br> MyDate = Now.AddDays(-5)<br> MyWeekDay = Weekday(MyDate) <br> return MyWeekDay<br>End Function<br><br>@#Returns the Month Integer<br>Function Date16()<br> Dim MyDate as DateTime<br> Dim MyMonth as Integer<br> MyDate = Now.AddDays(-5)<br> MyMonth = Month(MyDate) <br> return MyMonth<br>End Function<br><br>@#Returns just a formatted string<br>@#This method provides just formatting but <br>@#Very flexible with not a lot of code<br>Function Date17()<br> Dim MyDate as String<br> MyDate = Format(Now(), "yyyy")<br> return MyDate<br>End Function<br></script><br>[/vscript]<br>datetime 的一些通用函数 |
|