上一篇:在ASP.NET中操作文件的例子(VB) >>
在ASP.NET中处理 datetime 的一些通用函数(vb)
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动态生成图像(转2) >>
相关文章:
- · ASP+全新接触(1) {转}
- · 就是那个上传的。按实际上传时的文件名称保存(不在是test.jpg了)图片可以改大小,图上写字(可选字体...
- · ASP+全新接触(2) {转}
- · 用asp.net写的论坛程序
- · forum.aspx 论坛主页
- · reply.aspx 浏览贴子内容及回复
- · postmessage.aspx 上贴保存
- · .net的几个重要问题
- · 解决问题的方法:(JspFuns与开心的对话录)
- · 控件发布:带日期标注的日历控件。
- · 续上文:由于16K的限制,只能再接一节了。
- · 为什么我在中文win2000+sp1上装的vs.net不能创建各种web application,而英...
- · ASP.NET中密码保护,MD5和SHA1算法的使用
- · ASP。NET连SQL7接口源代码?
- · 我对.Net技术中asp.net应用的一点看法
- · 从一个舆论调查的制作谈面向对象的编程思路(一)
- · 从一个舆论调查的制作谈面向对象的编程思路(二)
- · 从一个舆论调查的制作谈面向对象的编程思路(三)
- · 从一个舆论调查的制作谈面向对象的编程思路(五)
- · 在asp.net中使用组件,也包括import和asemble的区别
- · 从一个舆论调查的制作谈面向对象的编程思路(四)
- · 分别用DataGrid、Repeater、DataList绑定XML数据的例子
- · 用DataList 控制元件开发的一个简单的留言本程序:
- · .Net边学边讲(二)
- · .Net边学边讲(一)
- · 里面是对一个body的属性进行server的一些设定,不过可以衍生到其他的一些htmlcontrol新手看看,或者有点...
- · 一个实现自定义event的文章。。。我还没有完全摸透。。不知道有没人有兴趣。。新手就不用看了,先学会走...
- · Server.Transfer,Response.Redirect 和 Page.Navigate 的区别
- · ASP.NET发送ICQ消息DIY
- · web页面用水晶报表的例子
- · Creating Custom Portal Modules
- · 几个.net的重要问题
- · SQL命令中DateTime格式参考
- · 关于webcontrol和pagelet的一点看法
- · 关于.net的几个重要问题的bigeagle版本
- · 关于datagrid的使用以及动态修改,以及使用存储过程的介绍
- · 转阿土伯推荐的文章:在 VS.NET 中编写 Web 应用程序(附图)(推荐)
- · 转新技术网:在ASP.NET中使用.NET组件
