'**********************************************************************
' GetLocalTime
' パソコンの現在日時をミリ秒単位で取得
'**********************************************************************
Option Explicit
'SYSTEMTIME
' wYear As Integer
' wMonth As Integer
' wDayOfWeek As Integer '0=日曜日 / 1=月曜日 ...
' wHour As Integer
' wMinute As Integer
' wSecond As Integer
' wMillseconds As Integer
#If VBA7 Then
Declare PtrSafe Sub GetLocalTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
#Else
Declare Sub GetLocalTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
#End If
'**********************************************************************
' 現在日時の取得 (ミリ秒単位)
' input :
' return : 現在日時 (yyyy/mm/dd hh:mm:ss.mmm)
' note :
'**********************************************************************
Function Get_DateTime() As String
Dim datetime As String
Dim t As SYSTEMTIME
Call GetLocalTime(t)
datetime = Format(t.wYear, "0000") & "/" & Format(t.wMonth, "00") & "/" & Format(t.wDay, "00") & _
" " & _
Format(t.wHour, "00") & ":" & Format(t.wMinute, "00") & ":" & Format(t.wSecond, "00") & _
"." & _
Format(t.wMilliseconds, "000")
Get_DateTime = datetime
End Function
目次
コメント