Skip to content

Instantly share code, notes, and snippets.

@martinusso
Last active March 30, 2016 13:59
Show Gist options
  • Save martinusso/4c3d27bb9be19af81089 to your computer and use it in GitHub Desktop.
Save martinusso/4c3d27bb9be19af81089 to your computer and use it in GitHub Desktop.
Find out current local time in Time Zone – UTC
var
TimeZoneInfo: TTimezoneinformation;
Minutes: Integer;
Sign: string;
begin
if not (GetTimezoneInformation(TimeZoneInfo) in [TIME_ZONE_ID_UNKNOWN, TIME_ZONE_ID_STANDARD, TIME_ZONE_ID_DAYLIGHT]) then
Result('');
Minutes := (TimeZoneInfo.Bias + TimeZoneInfo.DaylightBias) * -1;
if Minutes < 0 then
Sign := '-'
else
Sign := '+';
Result := Sign + FormatDateTime('hh:MM', IncMinute(0, Minutes));
end;
@martinusso
Copy link
Author

// C#
String.Format("{0:d/M/yyyy HH:mm:ss zzz}", DateTime.Now); // only uses zzz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment