XL 2016 Heure GMT (Temps universel)

dodineau

XLDnaute Occasionnel
Bonjour à toutes et tous.
Je recherche un code qui peux affecter à une variable la date et l'heure GMT.
Merci pour votre aide.
A+
 

Lone-wolf

XLDnaute Barbatruc
Bonsoir Modeste geedee, dodineau :)

À mettre dans un module standard

VB:
Option Explicit

Private Declare PtrSafe Sub GetSystemTime Lib "Kernel32" (ByRef lpSystemTime As SYSTEMTIME)

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

Function GMT() As Date
    Dim nowGmt As SYSTEMTIME
    Application.Volatile
    Call GetSystemTime(nowGmt)
    GMT = DateValue(nowGmt.wDay & "/" & nowGmt.wMonth & "/" & nowGmt.wYear) + (nowGmt.wHour + 2) / 24 + nowGmt.wMinute / 24 / 60 + nowGmt.wSecond / 24 / 3600
End Function

Public Sub Test()
Dim dt As Date

    dt = GMT
    Range("d2") = dt      'à adapter
End Sub

gmt.gif
 

Discussions similaires

Réponses
9
Affichages
362

Statistiques des forums

Discussions
312 024
Messages
2 084 722
Membres
102 638
dernier inscrit
TOTO33000