Icon View Thread

The following is the text of the current message along with any replies.
Messages 11 to 13 of 13 total
Thread DateTime (EWB) <-> TDateTime (Delphi)
Wed, Jul 20 2016 3:55 AMPermanent Link


>>The EWB time functions have an optional  USEUTC parameter except DateTimeToISOStr() which I believe always converts to UTC time, which >>we old farts call Grenich mean time..

Hi Erick,

Yeah, but the DateTimeToISOStr is used when you pass dtfISO8601 to the TWriter constructor.

"Append(IntToStr(Integer(Value)))" is just typecasting the DateTime value.

So I would assume code like this:

 LDate: DateTime;
 LDate := Date;

would contain an integer value representation of today's date.

But when I use Walter's method above in Delphi to convert this to a Delphi TDateTime I get this:

19/07/16 22:00:00

Now, if I write:

LDate := Now;

I get this:

20/07/16 07:50:25

which has the correct date but uses GMT. I have my PC set to (UTC+01:00) Brussels, Copenhagen, Madrid, Paris so the correct time should be 09:50:25.

// Thom
Wed, Jul 20 2016 6:09 AMPermanent Link

Walter Matte

Tactical Business Corporation

I wrote my own server too, so I convert date and time as they are locally - I don't want localization most of the time..

But EWB will localize date to the timezone.    I don't want that 99% of the time.  So I adjust on the EWB side.

function NowFix : DateTime;
 result := Now - (TimeZoneOffSet(now) * 60 * 1000);

// DisplayDate is my own routine to format dates - but AsDateTime will localize so I correct to unlocalize
function TfrmTime.TimeDetWorkDateGetText(Sender: TObject; const Value: String): String;
 result := DisplayDate(TimeDet.Columns['WorkDate'].AsDateTime + (TimeZoneOffSet(now) * 60 * 1000), 2);

Wed, Jul 20 2016 11:45 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.


Email timyoung@elevatesoft.com


<< What do you mean "localize DateTime values" ? >>

When you use the Date() function, you're getting a DateTime value that is the number of msecs since midnight, January 1, 1970, UTC.

If you pass this to your server-side code, then you may need to convert the date from UTC to local time in order to have any database updates, etc. reflect the local time instead of the UTC time.

Tim Young
Elevate Software
Previous PagePage 2 of 2
Jump to Page:  1 2