vb点虐 日期时间的简单介绍

vb点虐 中怎么获取日期中的年月日时分秒

Dim ThisDay As String = Format(Now, "yyyy-MM-dd") '获得当前日期字符串

珠海网站建设公司成都创新互联公司,珠海网站设计制作,有大型网站制作公司丰富经验。已为珠海近1000家提供企业网站建设服务。企业网站搭建\外贸网站制作要多少钱,请找那个售后服务好的珠海做网站的公司定做!

Dim ThisDateTime As DateTime = Convert.ToDateTime(ThisDay) '当前日期转换成DateTime

Dim ThisWeekDay As Integer = ThisDateTime.DayOfWeek '获得当前日期是星期几

Dim differadd As Integer = 1 - ThisWeekDay '相差的天数(星期1与当前星期几相差的天数)

Dim MyAdd As New TimeSpan(differadd, 0, 0, 0)

Dim MyYear As Integer = Format(Now, "yyyy") '获取当前日期的年份

Dim MyMonth As Integer = Format(Now, "MM") '获取当前日期的月份

Dim MyDay As Integer = Format(Now, "dd") '获取当前日期是几号

Dim MyToday As DateTime = New DateTime(MyYear, MyMonth, MyDay)

Dim Yourday As DateTime = MyToday.Add(MyAdd)

MsgBox("本周星期一的日期是:" Yourday)

vb点虐 如何获取时间?

两种方式自己选用

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim s As String

s = DateTime.Today.Year()

s = s DateTime.Today.Month()

s = s DateTime.Today.Day()

s = s DateTime.Now.Hour()

s = s DateTime.Now.Minute()

s = s DateTime.Now.Second()

MsgBox(s, vbDefaultButton1, Now())

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim s As String

s = Format(Now(), "yyyymmddhhmmss")

MsgBox(s, vbYes, Now())

End Sub

VB点虐 获取日期

dim myMonth as string= DateTime.Now.tostring("MM")

年月日时分秒

DateTime.Now.tostring("yyyy-MM-dd hh-dd-ss") ‘得到2011-03-30 09-08-05

DateTime.Now.tostring("yy-M-d h-d-s") ‘得到11-3-30 9-8-5


分享标题:vb点虐 日期时间的简单介绍
文章链接:http://pwwzsj.com/article/ddjjcoj.html