大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
可以访问注册表HKEY_CURRENT_USER\Control Panel\International下面的一些键值
创新互联是一家集网站建设,东乡族企业网站建设,东乡族品牌网站建设,网站定制,东乡族网站建设报价,网络营销,网络优化,东乡族网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。
如sShortDate键值表示的是短日期sLongDate表示的是长日期
中文下的短日期是 yyyy-M-d
中文下的长日期是 yyyy'年'M'月'd'日'
VB里有好多时间函数,使用方法和excel类似,直接调用就好了,比如now显示当前时间,today表示当前日期,又如year年,month月,day日,hour小时(24小时制),minute分,second秒;
另外要想获得想要的时间格式,你需要一个格式函数Formart(),表示为formart(date,formart of date),比如我想获得今天的日期并且用这种格式2015-08-31,那么函数是formart(now,"ddddd"),这里的ddddd就是格式符,想要获得全部的格式符可以百度“formart()函数使用“,我这里就不引用了,希望以上内容对你有帮助
最简单的办法是用Shell调用NET TIME //servername 命令获得时间,你可以将输出重定向到一个文件,然后在VB读取这个文件以获得时间。 ---------------------------------------或者服务器上有SQL服务的话,可以:Set DbC = New ADODB.Connection
Dim adoDateTime As New ADODB.Recordset '获取 NT-SERVER 时间
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函数获得服务器的时间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
'要运行该程序,通过如下方式调用。
Private Sub Command1_Click()
Dim d As Date
d = getRemoteTOD("\\trademark")
MsgBox d
End Sub
用日期函数day()可获得当前日期,time()可获得当前系统时间.
dim CurDay as string
dim CurTime as string
curday=day()
curtime=time()
Label1.Caption = Date
就能在Label16显示当前日期
now 这个函数可以获得当前系统时间(包括年月日,小时分钟秒)
而
year()
month()
day()
等等则可以从now返回的值中分别提取年,月,日的信息