用日期函數(shù)day()可獲得當(dāng)前日期,time()可獲得當(dāng)前系統(tǒng)時(shí)間.
創(chuàng)新互聯(lián)是少有的成都網(wǎng)站建設(shè)、做網(wǎng)站、營(yíng)銷(xiāo)型企業(yè)網(wǎng)站、微信小程序、手機(jī)APP,開(kāi)發(fā)、制作、設(shè)計(jì)、買(mǎi)鏈接、推廣優(yōu)化一站式服務(wù)網(wǎng)絡(luò)公司,于2013年開(kāi)始,堅(jiān)持透明化,價(jià)格低,無(wú)套路經(jīng)營(yíng)理念。讓網(wǎng)頁(yè)驚喜每一位訪客多年來(lái)深受用戶(hù)好評(píng)
dim CurDay as string
dim CurTime as string
curday=day()
curtime=time()
Label1.Caption = Date
就能在Label16顯示當(dāng)前日期
now 這個(gè)函數(shù)可以獲得當(dāng)前系統(tǒng)時(shí)間(包括年月日,小時(shí)分鐘秒)
而
year()
month()
day()
等等則可以從now返回的值中分別提取年,月,日的信息
兩種方式自己選用
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") '獲得當(dāng)前日期字符串
Dim ThisDateTime As DateTime = Convert.ToDateTime(ThisDay) '當(dāng)前日期轉(zhuǎn)換成DateTime
Dim ThisWeekDay As Integer = ThisDateTime.DayOfWeek '獲得當(dāng)前日期是星期幾
Dim differadd As Integer = 1 - ThisWeekDay '相差的天數(shù)(星期1與當(dāng)前星期幾相差的天數(shù))
Dim MyAdd As New TimeSpan(differadd, 0, 0, 0)
Dim MyYear As Integer = Format(Now, "yyyy") '獲取當(dāng)前日期的年份
Dim MyMonth As Integer = Format(Now, "MM") '獲取當(dāng)前日期的月份
Dim MyDay As Integer = Format(Now, "dd") '獲取當(dāng)前日期是幾號(hào)
Dim MyToday As DateTime = New DateTime(MyYear, MyMonth, MyDay)
Dim Yourday As DateTime = MyToday.Add(MyAdd)
MsgBox("本周星期一的日期是:" Yourday)
dim myMonth as string= DateTime.Now.tostring("MM")
年月日時(shí)分秒
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
Date.Now() As Date ’日期時(shí)間
這可以在對(duì)象瀏覽器中查一查嗎。
Date.Date() As Date '日期
Date.Time() As Date ‘時(shí)間
dim 現(xiàn)在的時(shí)間 as date = Now
"Select * From 表 Where 開(kāi)始的時(shí)間= # " 現(xiàn)在的時(shí)間 "# And 結(jié)束的時(shí)間= # " 現(xiàn)在的時(shí)間 " # "
本文名稱(chēng):vbnet獲取日期 vb獲取時(shí)間
網(wǎng)頁(yè)URL:http://m.rwnh.cn/article20/hhgjjo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供手機(jī)網(wǎng)站建設(shè)、Google、網(wǎng)頁(yè)設(shè)計(jì)公司、網(wǎng)站設(shè)計(jì)、網(wǎng)站策劃、網(wǎng)站維護(hù)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)