不是 有 函數(shù)嘛?
創(chuàng)新互聯(lián)建站主要從事網(wǎng)站設計、成都網(wǎng)站設計、網(wǎng)頁設計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務。立足成都服務察雅,10多年網(wǎng)站建設經(jīng)驗,價格優(yōu)惠、服務專業(yè),歡迎來電咨詢建站服務:028-86922220
now() 就是 吧
取得 后 再 分離出你所需的,分別賦值 就行了,當然 還是 有 函數(shù)的
兩種方式自己選用
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
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 '相差的天數(shù)(星期1與當前星期幾相差的天數(shù))
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)
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 '相差的天數(shù)(星期1與當前星期幾相差的天數(shù))
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時間取年月的詞條
當前URL:http://jinyejixie.com/article12/dopeodc.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供微信公眾號、電子商務、小程序開發(fā)、動態(tài)網(wǎng)站、服務器托管、關鍵詞優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)