Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2012-03

Is there a function that returns UTC time in FPC or Lazarus?

6 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Frank Church

When I get the time via the DateTime function result is adapted for the timezone, making it an hour ahead now?

Is there a function that returns the UTC time, either as a UnixTime or TDateTime irregardless of timezone?

Frank Church ======================= http://devblog.brahmancreations.com
Reinier Olislagers
to Frank Church
Frank Church wrote 6 lines
When I get the time via the DateTime function result is adapted for the timezone, making it an hour ahead now? Is there a function that returns the UTC time, either as a UnixTime or TDateTime irregardless of timezone?

Frank,

You could search the fpc and lazarus mailing list; I know there've been posts regarding this.
IIRC, the conclusion was that doing this is potentially very difficult to do cross platform, keeping daylight saving changes etc in mind.

There is a separate unit that deals with this, IIRC, the wiki mentions it somewhere..

Regards,
Reinier

João Marcelo Vaz
to Reinier Olislagers

2012/3/30 Reinier Olislagers

Show quoted text 22 lines
On 30-3-2012 16:05, Frank Church wrote: > When I get the time via the DateTime function result is adapted for > the timezone, making it an hour ahead now? > > Is there a function that returns the UTC time, either as a UnixTime or > TDateTime irregardless of timezone? > Frank, You could search the fpc and lazarus mailing list; I know there've been posts regarding this. IIRC, the conclusion was that doing this is potentially very difficult to do cross platform, keeping daylight saving changes etc in mind. There is a separate unit that deals with this, IIRC, the wiki mentions it somewhere.. Regards, Reinier --

PascalTZ does that.

http://wiki.lazarus.freepascal.org/PascalTZ

waldo kitty
to Reinier Olislagers: You could search the fpc and lazarus mailing list; I know there've been posts regarding…
Reinier Olislagers wrote 13 lines
On 30-3-2012 16:05, Frank Church wrote: > When I get the time via the DateTime function result is adapted for > the timezone, making it an hour ahead now? > > Is there a function that returns the UTC time, either as a UnixTime or > TDateTime irregardless of timezone? > Frank, You could search the fpc and lazarus mailing list; I know there've been posts regarding this. IIRC, the conclusion was that doing this is potentially very difficult to do cross platform, keeping daylight saving changes etc in mind.

agreed... even in the TP/BP6/7 days... it depends on the setting of the local clock as to whether you to daylight saving display or not... i know of many that operate on UTC and do not do local time when viewing... it can be done but it is going to be a "trick" ;)

Reinier Olislagers
to João Marcelo Vaz: 2012/3/30 Reinier Olislagers PascalTZ does that.…
João Marcelo Vaz wrote 14 lines
2012/3/30 Reinier Olislagers < > On 30-3-2012 16:05, Frank Church wrote: > Is there a function that returns the UTC time, either as a UnixTime or > TDateTime irregardless of timezone? There is a separate unit that deals with this, IIRC, the wiki mentions it somewhere.. Regards, Reinier PascalTZ does that. http://wiki.lazarus.freepascal.org/PascalTZ

Thanks, João, that's the one I meant!

Reinier

Frank Church
to Frank Church: When I get the time via the DateTime function result is adapted for the timezone, making…
Frank Church wrote 11 lines
When I get the time via the DateTime function result is adapted for the timezone, making it an hour ahead now? Is there a function that returns the UTC time, either as a UnixTime or TDateTime irregardless of timezone? -- Frank Church ======================= http://devblog.brahmancreations.com

PascalTZ appears to be the most recommended one. I will go with it and see. If it comes to the worst, I will consider looking up the time from an NTP server to see how it compares as a check.

Frank Church ======================= http://devblog.brahmancreations.com