-1

Please I Need a Function to Convert a UTC DateTime to GMT Format. This Function Should Receive the UTC DateTime as a TDateTime and Return The GMT Time as a String.

Google Does Not Seem to Help Much.

Here is an Illustration

Current Value in UTC DateTime := 7/9/2014 11:36:51 PM

Needed Value in GMT Time := 2014-07-09 23:36:51

Delphi Version : XE5

Thanks.

Xor-el
  • 242
  • 4
  • 11
  • I find Chris Rolliston's book titled 'Delphi XE2 Foundations' to be a priceless resource for questions like this. Don't be thrown off by the 'XE2' in the title, it's relevant through XE6. – Jason Enochs Jul 14 '14 at 12:48
  • You mentioned the output needs to be a string. You can do the format conversion AND the type conversion at the same time using 'DateTimeToString' --- Documentation: http://docwiki.embarcadero.com/Libraries/XE6/en/System.SysUtils.DateTimeToString – Jason Enochs Jul 14 '14 at 13:33

1 Answers1

2

Use FormatDateTime for this.

The documentation describes the format string options in detail. The format string that you need is:

yyyy-mm-dd hh:nn:ss
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490