成都创新互联网站制作重庆分公司

vb.net获得日期,vb 获取当前日期

vb.net 求日期的, 出来的结果是 2011-06-11. 21:22:30 , 如果我不想要几点几分,怎么弄?

用Date直接得到日期,不要用now。

10年积累的网站设计、成都做网站经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先做网站设计后付款的网站建设流程,更有尚志免费网站建设让你可以放心的选择与我们合作。

有格式方面的要求,再用 format

vb.net中怎么获取日期中的年月日时分秒

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

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.net中如何获取当前日期所在星期的星期一的具体年月日

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

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.net 随机生成日期

1.随机生成日期

Format(DateSerial(Rnd * 100, Rnd * 12, Rnd * 31), "yyyymmdd")

2.用函数IsDate()

---------------------------------------------

Debug.WriteLine(Format(DateSerial(Rnd() * 100, Rnd() * 12, Rnd() * 31), "yyyy-MM-dd"))

debug:1971-06-18

笔误,你把yyyymmdd换成yyyy-MM-dd这样试验一下。

我测试了没问题的

vb.net 如何获取时间?

两种方式自己选用

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.net如何获取时间格式?

可以访问注册表HKEY_CURRENT_USER\Control Panel\International下面的一些键值

如sShortDate键值表示的是短日期sLongDate表示的是长日期

中文下的短日期是 yyyy-M-d

中文下的长日期是 yyyy'年'M'月'd'日'


分享题目:vb.net获得日期,vb 获取当前日期
标题URL:http://cxhlcq.com/article/dsgghih.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部