您尚未登录,请登录后浏览更多内容! 登录 | 立即注册

QQ登录

只需一步,快速开始

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 3697|回复: 1

datetime 的一些通用函数

[复制链接]

49

主题

0

听众

59

积分

初级程序员

Rank: 5

性别
保密
听众数
0
买家信用
卖家信用
在线时间
0 小时
相册
0

社区元老勋章 无私奉献勋章

发表于 2006-8-8 16:23:00 |显示全部楼层
程序员装备

[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(&quot;MM/dd/yyyy&quot;, 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(&quot;{0:d}&quot;,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(&quot;{0:MM/dd/yyyy}&quot;,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(&quot;{0:dddd}&quot;,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(), &quot;yyyy&quot;)<br>  return MyDate<br>End Function<br>&lt;/script&gt;<br>[/vscript]<br>datetime 的一些通用函数

1

主题

0

听众

7

积分

应届毕业生

Rank: 1

性别
保密
听众数
0
买家信用
卖家信用
在线时间
0 小时
相册
0
发表于 2007-10-31 23:11:00 |显示全部楼层

回复:datetime 的一些通用函数

好像有些深哦
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册


关闭

站长推荐上一条 /1 下一条



      
    Archiver|手机版|臣迅电子商务|网站地图|渝ICP备11003388号

GMT+8, 2012-5-20 09:16

© 2001-2011 Powered by Discuz! X2.5. Theme By Yeei! update By CNNTEC

webSite begin 2005

回顶部