Converting UTC date/time value to local computer time with Windows settings of local GMT shifting; rules for transition to summertime.
function UTCToLocalTime(dt: double): double;
Parameter |
Type |
Value |
dt |
double |
UTC date/time value from which you need to obtain the local value. |
Date/time value.
var
dt: double;
begin
dt := EncodeDateTime(2017, 12, 7, 17, 6, 46, 0);
mLogScript(' Date and time: ' + FormatDateTime('mm.dd.yyyy hh:nn:ss', dt), '');
dt := UTCToLocalTime(dt);
mLogScript('Date and time in UTC: ' + FormatDateTime('mm.dd.yyyy hh:nn:ss', dt), '');
end.
[17:08:37] (Log "UTCToLocalTime"): Date and time: 12.07.2017 17:06:46
[17:08:37] (Log "UTCToLocalTime"): Date and time in UTC: 12.07.2017 19:06:46
[17:08:37] (Run "UTCToLocalTime"): Script operation time: 5 ms
[17:08:37] (Run "UTCToLocalTime"): Script done successfully.