Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Timestamp to valid Delphi's datetime (https://www.delphipraxis.net/176617-timestamp-valid-delphis-datetime.html)

WojTec 17. Sep 2013 09:52

Delphi-Version: 2010

Timestamp to valid Delphi's datetime
 
I want to know datatime of PE compilation. So, I learned a bit about PE and finally got TimeDateStamp field in PE header. Unfortunately this is cardinal value and it's useless in Delphi. So, I performed conversion:

Delphi-Quellcode:
FormatDateTime('c', EncodeDate(1970, 1, 1) + h.TimeDateStamp / 86400)
Code:
TimeDateStamp = 1379407669
DateTime = 17.09.13 08:47:49
Result is 2hrs back. Question: I did wrong conversion or need to add 2hrs in any case?

mkinzler 17. Sep 2013 09:59

AW: Timestamp to valid Delphi's datetime
 
You have to adapt to your timezone. Timestamp is GMT

WojTec 17. Sep 2013 10:45

Re: Timestamp to valid Delphi's datetime
 
Hm, I don't know how, because timestamp is -2, but my GMT is +1.

I have:

Delphi-Quellcode:
(EncodeDate(1970, 1, 1) + 1379407669 {timestamp} / 86400) + ((1 / 24) {hour} + (TimeZone.Bias / 60);

DeddyH 17. Sep 2013 10:59

AW: Timestamp to valid Delphi's datetime
 
Try DateUtils.TTimeZone.Local.ToLocalTime(your DateTime-value).

WojTec 17. Sep 2013 11:23

Re: Timestamp to valid Delphi's datetime
 
This is for DXE2+, I guess? I have D2010 and such goodies are absent. How to in 'old classic' style?

Uwe Raabe 17. Sep 2013 12:09

AW: Re: Timestamp to valid Delphi's datetime
 
Zitat:

Zitat von WojTec (Beitrag 1228776)
Hm, I don't know how, because timestamp is -2, but my GMT is +1.

What about Daylight Saving Time?

WojTec 17. Sep 2013 14:24

Re: AW: Re: Timestamp to valid Delphi's datetime
 
Zitat:

Zitat von Uwe Raabe (Beitrag 1228797)
What about Daylight Saving Time?

What you mean? TimeZone.Bias + TimeZone.DaylightBias? I don't know :(


Alle Zeitangaben in WEZ +1. Es ist jetzt 07:35 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz