站长首页  新闻资讯  网站运营  网站源码  站长学院  赚钱联盟  站长论坛  链接交换  素材中心  站长工具
设为主页
收藏本站
寻找帮助
 学院首页 | 网络编程 | 网页设计 | 图形图象 | 数 据 库 | 服务器技术 | 网络安全 | 网络媒体 | 搜索排名 | 网站运营 |
 当前位置:站长前线 >> 站长学院 >> 网络编程 >> .NET教程 >> 在ASP.NET中处理 datetime 的一些通用函数(vb)
∷ 相关文章 ∷
在ASP.NET中处理 datetime..
在ASP中使用SQL语句之3:LI..
在ASP中用集合成批操作..
树型结构在ASP中的简单解决..
在ASP中按指定参数格式化显..
在asp中通过getrows实现数..
在asp中结合对象和组件
∷ 热门文章 ∷
网吧生存手册:10秒钟还你..
密码攻防实战:驱动器隐藏..
木马入侵手段及防范措施
PhotoShop 学习方法论简单..
ASP.NET下MVC设计模式的实..
使用Win2003搭建视频服务器..
asp.net StreamReader 创建..
代理商之痛(转互联网大会..
Linux 服务器的安全隐患以..
用VB实现一个简单的ESMTP客..
 
在ASP.NET中处理 datetime 的一些通用函数(vb)
作者:未知   来源:CSDN   发布日期:2004-6-25   点击次数: 1837
在ASP.NET中处理 datetime 的一些通用函数(vb)
'Uses the Timespan method to subtract a certain number of days
Function Date1()
Dim NewTime as DateTime
NewTime = DateTime.Now.Subtract( New TimeSpan(7, 0, 0, 0) )
NewTime = NewTime.Format("MM/dd/yyyy", DateTimeFormatInfo)
response.write(NewTime)
End Function

'Uses the AddDays method to subtract X number of days
Public Function Date2()
Dim NewTime as DateTime
NewTime = DateTime.Now.AddDays(-7)
Dim s as string = NewTime
return s
End Function

'Thanks to Paul Czywczynski for this idea
'This probably (In My opinion) Offers the most flexibility found so far
'Change where the MM/dd/yyyy to whatever
'response.write(System.String.Format("{0:d}",NewTime))
'would return just the name of the Day
Function Date3()
Dim NewTime as DateTime = now.addDays(-7)
response.write(System.String.Format("{0:MM/dd/yyyy}",NewTime))
End Function


Function Date4()
Dim NewTime as DateTime
NewTime = now.addDays(-7)
return NewTime.ToString()
End Function

'Uses the toLongTimeString method
Public Function Date5()
Dim NewTime as DateTime
NewTime = Now()
return newtime.toLongTimeString()
End Function

'Uses the toShortTimeString method
Public Function Date6()
Dim NewTime as DateTime
NewTime = Now()
return newtime.toShortTimeString()
End Function

'Uses the toLongDateString method
Public Function Date7()
Dim NewTime as DateTime
NewTime = Now()
return newtime.toLongDateString()
End Function

'Uses the toShortDateString method
Public Function Date8()
Dim NewTime as DateTime
NewTime = Now()
return newtime.toShortDatestring()
End Function

'Uses FormatDateTime function General format
Function Date9()
Dim NewTime as DateTime
NewTime = DateTime.Now.Subtract( New TimeSpan(7, 0, 0, 0) )
return formatdatetime(NewTime, 0)
End Function

'Uses FormatDateTime function LongDate format
Function Date10()
Dim NewTime as DateTime
NewTime = DateTime.Now.Subtract( New TimeSpan(7, 0, 0, 0) )
return formatdatetime(NewTime, 1)
End Function

'Uses FormatDateTime function ShortDate format
Function Date11()
Dim NewTime as DateTime
NewTime = DateTime.Now.Subtract( New TimeSpan(7, 0, 0, 0) )
return formatdatetime(NewTime, 2)
End Function

'Uses FormatDateTime function LongTime format
Function Date12()
Dim NewTime as DateTime
NewTime = DateTime.Now.Subtract( New TimeSpan(7, 0, 0, 0) )
return formatdatetime(NewTime, 3)
End Function

'Uses FormatDateTime function ShortTime format
Function Date13()
Dim NewTime as DateTime
NewTime = DateTime.Now.Subtract( New TimeSpan(7, 0, 0, 0) )
return formatdatetime(NewTime, 4)
End Function

'Bring Back just the name of the Day
Function Date14()
Dim NewTime as DateTime = now.addDays(-7)
dim s as string
s = (System.String.Format("{0:dddd}",NewTime))
Return s
End Function

'Returns the Integer of what day of week
Function Date15()
Dim MyDate as DateTime
Dim MyWeekDay as Integer
MyDate = Now.AddDays(-5)
MyWeekDay = Weekday(MyDate)
return MyWeekDay
End Function

'Returns the Month Integer
Function Date16()
Dim MyDate as DateTime
Dim MyMonth as Integer
MyDate = Now.AddDays(-5)
MyMonth = Month(MyDate)
return MyMonth
End Function

'Returns just a formatted string
'This method provides just formatting but
'Very flexible with not a lot of code
Function Date17()
Dim MyDate as String
MyDate = Format(Now(), "yyyy")
return MyDate
End Function
</script>


[告诉好友] [关闭窗口] [返回上一页] [打 印]

  • 上篇文章:在ASP.NET中操作文件的例子(VB)
  • 下篇文章:C#的前途如何?
  • 关于本站 版权申明 广告服务 友情链接 寻找帮助 联系我们 人才招聘
    Copyright © 2002-2006 Zzadmin.Com. All Rights Reserved .
    Powered by:Zzadmin.com
    本站资源搜集于网络与本站无关如有侵权请来信指出!