可以訪問注冊表HKEY_CURRENT_USER\Control Panel\International下面的一些鍵值
創(chuàng)新互聯(lián)是一家集網(wǎng)站建設(shè),東鄉(xiāng)族企業(yè)網(wǎng)站建設(shè),東鄉(xiāng)族品牌網(wǎng)站建設(shè),網(wǎng)站定制,東鄉(xiāng)族網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營銷,網(wǎng)絡(luò)優(yōu)化,東鄉(xiāng)族網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競爭力。可充分滿足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。
如sShortDate鍵值表示的是短日期sLongDate表示的是長日期
中文下的短日期是 yyyy-M-d
中文下的長日期是 yyyy'年'M'月'd'日'
VB里有好多時(shí)間函數(shù),使用方法和excel類似,直接調(diào)用就好了,比如now顯示當(dāng)前時(shí)間,today表示當(dāng)前日期,又如year年,month月,day日,hour小時(shí)(24小時(shí)制),minute分,second秒;
另外要想獲得想要的時(shí)間格式,你需要一個(gè)格式函數(shù)Formart(),表示為formart(date,formart of date),比如我想獲得今天的日期并且用這種格式2015-08-31,那么函數(shù)是formart(now,"ddddd"),這里的ddddd就是格式符,想要獲得全部的格式符可以百度“formart()函數(shù)使用“,我這里就不引用了,希望以上內(nèi)容對你有幫助
最簡單的辦法是用Shell調(diào)用NET TIME //servername 命令獲得時(shí)間,你可以將輸出重定向到一個(gè)文件,然后在VB讀取這個(gè)文件以獲得時(shí)間。 ---------------------------------------或者服務(wù)器上有SQL服務(wù)的話,可以:Set DbC = New ADODB.Connection
Dim adoDateTime As New ADODB.Recordset '獲取 NT-SERVER 時(shí)間
With DbC
If .State = adStateOpen Then .Close
.CursorLocation = adUseClient
.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=" Server ";UID=" uID ";PWD=" uPassword ";DATABASE=" MyDatabase ";OPTION=1 + 2 + 8 + 32 + 2048 + 163841"
.ConnectionTimeout = 90
.Open
adoDateTime.Open "select now() as mysqlTime"
End With ————————————————————————————————————————————使用Windows API的NetRemoteTOD函數(shù)獲得服務(wù)器的時(shí)間Option Explicit
Private Declare Function NetRemoteTOD Lib "Netapi32.dll" ( _
tServer As Any, pBuffer As Long) As Long
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Private Type TIME_ZONE_INFORMATION
Bias As Long
StandardName(32) As Integer
StandardDate As SYSTEMTIME
StandardBias As Long
DaylightName(32) As Integer
DaylightDate As SYSTEMTIME
DaylightBias As Long
End Type
Private Declare Function GetTimeZoneInformation Lib "kernel32" (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long
Private Declare Function NetApiBufferFree Lib "Netapi32.dll" (ByVal lpBuffer As Long) As Long
'
Private Type TIME_OF_DAY_INFO
tod_elapsedt As Long
tod_msecs As Long
tod_hours As Long
tod_mins As Long
tod_secs As Long
tod_hunds As Long
tod_timezone As Long
tod_tinterval As Long
tod_day As Long
tod_month As Long
tod_year As Long
tod_weekday As Long
End Type
'
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public Function getRemoteTOD(ByVal strServer As String) As Date
Dim result As Date
Dim lRet As Long
Dim tod As TIME_OF_DAY_INFO
Dim lpbuff As Long
Dim tServer() As Byte
tServer = strServer vbNullChar
lRet = NetRemoteTOD(tServer(0), lpbuff)
If lRet = 0 Then
CopyMemory tod, ByVal lpbuff, Len(tod)
NetApiBufferFree lpbuff
result = DateSerial(tod.tod_year, tod.tod_month, tod.tod_day) + _
TimeSerial(tod.tod_hours, tod.tod_mins - tod.tod_timezone, tod.tod_secs)
getRemoteTOD = result
Else
Err.Raise Number:=vbObjectError + 1001, _
Description:="cannot get remote TOD"
End If
End Function
'要運(yùn)行該程序,通過如下方式調(diào)用。
Private Sub Command1_Click()
Dim d As Date
d = getRemoteTOD("\\trademark")
MsgBox d
End Sub
用日期函數(shù)day()可獲得當(dāng)前日期,time()可獲得當(dāng)前系統(tǒng)時(shí)間.
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返回的值中分別提取年,月,日的信息