频道直达 - 学院 - 下载 - 交易 - 特效 - 字库 - 手册 -排名-工具- 繁體
网页教学网站开发 设为首页
加入收藏
联系我们
建站搜索: 常用广告代码   用户注册 | 用户登陆
您当前的位置:中国建站之家 -> 网站开发设计技术教程 -> Asp.Net教程 -> 在ASP.NET中处理datetime的一些通用函数(VB)

在ASP.NET中处理datetime的一些通用函数(VB)

作者:未知  来源:http://edu.chinaz.com  发布时间:2005-7-18 22:23:04  发布人:acx

减小字体 增大字体

'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>


将本文收藏到QQ书签与更多好友分享
[打 印]
[] [返回上一页] [收 藏]
下一篇文章:asp.NET特写
∷相关文章评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论...]
精彩推荐
热门文章
· 注册码大全二
· 注册码大全四
· 注册码大全一
· 要10G免费网络硬盘的请进..
· 通过google 赶快来赚美金..
· 注册码大全十
· 头像-qq头像(qq新头像)4..
· 让你轻松架设FTP服务器1..
· 注册码大全三
· 梦幻背景图片7
· 卡通动物图片6
· 网页制作素材-按钮素材2..
· 让你轻松架设FTP服务器5..
· 风景图片8
· 注册码大全九
· 让你轻松架设FTP服务器2..
关注此文读者还看过
· 微软提供的功能强大的AS..
· c:常用模块
· 嘟嘟网络陈艺光:诚信是..
· 实现聊天室在线人员无刷..
· asp性能测试第二部分(转..
· 新浪披露最新奖励措施 C..
· ASP 类 Class入门
· 一个简单的自动发送邮件..
· 关于无组上传的老话题
· PHP:路在何方?
· 3D教程:主持凳制作的简..
· 百度首吞营销下链 直销北..
· 突破防盗链
· PS调色教程:用通道为MM..
· 百度公布Q2财报 净利730..
· 梦幻背景图片4
相关文章
· 解析在ASP.NET中调用存储过..
· 推荐文章:在ASP.NET中创建..
· 在ASP页里面注册DLL的VBScr..
· 在ASP.NET AJAX中别使用mod..
· 如何在ASP程序中使用Telnet..
· 在ASP.NET中自动给URL加上超..
· 在ASP中使用事务控制
· 在ASP.NET页面中实现数据棒..
· 在ASP中常见的错误80004005..
· 在ASP中使用SQL语句之7:ORD..
· 在ASP中列出数据库中的表名..
· 在asp聊天室里实现房间功能..
· 在ASP处理程序时,进度显示..
· 在asp中调用jsp
· 在ASP中如何将代码生成的文..
· 在ASP中使用Java类(Using J..
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 - 人才招聘
网站合作、内容监督、商务咨询:QQ: 9576619
Copyright ? 2005--2008 中国建站之家版权所有
粤ICP备05092265号