|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
由于ASP还是一种Script语言所没除了大量使用组件外,没有办法提高其工作效率。它必须面对即时编绎的时间考验,同时我们还不知其背后的组件会是一个什么样的状况;UsestheTimespanmethodtosubtractacertainnumberofdays
FunctionDate1()
DimNewTimeasDateTime
NewTime=DateTime.Now.Subtract(NewTimeSpan(7,0,0,0))
NewTime=NewTime.Format("MM/dd/yyyy",DateTimeFormatInfo)
response.write(NewTime)
EndFunction
UsestheAddDaysmethodtosubtractXnumberofdays
PublicFunctionDate2()
DimNewTimeasDateTime
NewTime=DateTime.Now.AddDays(-7)
Dimsasstring=NewTime
returns
EndFunction
ThankstoPaulCzywczynskiforthisidea
Thisprobably(InMyopinion)Offersthemostflexibilityfoundsofar
ChangewheretheMM/dd/yyyytowhatever
response.write(System.String.Format("{0:d}",NewTime))
wouldreturnjustthenameoftheDay
FunctionDate3()
DimNewTimeasDateTime=now.addDays(-7)
response.write(System.String.Format("{0:MM/dd/yyyy}",NewTime))
EndFunction
FunctionDate4()
DimNewTimeasDateTime
NewTime=now.addDays(-7)
returnNewTime.ToString()
EndFunction
UsesthetoLongTimeStringmethod
PublicFunctionDate5()
DimNewTimeasDateTime
NewTime=Now()
returnnewtime.toLongTimeString()
EndFunction
UsesthetoShortTimeStringmethod
PublicFunctionDate6()
DimNewTimeasDateTime
NewTime=Now()
returnnewtime.toShortTimeString()
EndFunction
UsesthetoLongDateStringmethod
PublicFunctionDate7()
DimNewTimeasDateTime
NewTime=Now()
returnnewtime.toLongDateString()
EndFunction
UsesthetoShortDateStringmethod
PublicFunctionDate8()
DimNewTimeasDateTime
NewTime=Now()
returnnewtime.toShortDatestring()
EndFunction
UsesFormatDateTimefunctionGeneralformat
FunctionDate9()
DimNewTimeasDateTime
NewTime=DateTime.Now.Subtract(NewTimeSpan(7,0,0,0))
returnformatdatetime(NewTime,0)
EndFunction
UsesFormatDateTimefunctionLongDateformat
FunctionDate10()
DimNewTimeasDateTime
NewTime=DateTime.Now.Subtract(NewTimeSpan(7,0,0,0))
returnformatdatetime(NewTime,1)
EndFunction
UsesFormatDateTimefunctionShortDateformat
FunctionDate11()
DimNewTimeasDateTime
NewTime=DateTime.Now.Subtract(NewTimeSpan(7,0,0,0))
returnformatdatetime(NewTime,2)
EndFunction
UsesFormatDateTimefunctionLongTimeformat
FunctionDate12()
DimNewTimeasDateTime
NewTime=DateTime.Now.Subtract(NewTimeSpan(7,0,0,0))
returnformatdatetime(NewTime,3)
EndFunction
UsesFormatDateTimefunctionShortTimeformat
FunctionDate13()
DimNewTimeasDateTime
NewTime=DateTime.Now.Subtract(NewTimeSpan(7,0,0,0))
returnformatdatetime(NewTime,4)
EndFunction
BringBackjustthenameoftheDay
FunctionDate14()
DimNewTimeasDateTime=now.addDays(-7)
dimsasstring
s=(System.String.Format("{0:dddd}",NewTime))
Returns
EndFunction
ReturnstheIntegerofwhatdayofweek
FunctionDate15()
DimMyDateasDateTime
DimMyWeekDayasInteger
MyDate=Now.AddDays(-5)
MyWeekDay=Weekday(MyDate)
returnMyWeekDay
EndFunction
ReturnstheMonthInteger
FunctionDate16()
DimMyDateasDateTime
DimMyMonthasInteger
MyDate=Now.AddDays(-5)
MyMonth=Month(MyDate)
returnMyMonth
EndFunction
Returnsjustaformattedstring
Thismethodprovidesjustformattingbut
Veryflexiblewithnotalotofcode
FunctionDate17()
DimMyDateasString
MyDate=Format(Now(),"yyyy")
returnMyDate
EndFunction
</script>
大家可以自己去看一看.可以说看得想呕吐.以前有次下了个动网来看.里面连基本内置函数的保护措施(函数没防御性)都没有.难怪经常补这个补那个了.可能现在.NET版会好点吧 |
|