Sign in Join

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

Mailing lists / fpc-pascal / 2011-11

Convert unix timestamp to TDateTime

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Stathis Gkotsis

Hello,

I would like to convert a unix timestamp to TDateTime taking into account timezone and daylight savings. For example, timestamp: 1308666350 should be converted to: 2011/06/21 16:25:50, assuming GMT+1 timezone in the winter (GMT+2 in the summer). I would like this conversion to work both during the summer and the winter, meaning that if I try to convert the above timezone during the winter time, it should work as well. So, I would like for the conversion to work similarly to: date -d @1308666350 +%Y/%m/%d\ %H:%M:%S . Is this something possible?

Thank you,

Stathis

José Mejuto
to Stathis Gkotsis

Hello FPC-Pascal,

Friday, November 18, 2011, 1:54:13 PM, you wrote:

SG> I would like to convert a unix timestamp to TDateTime taking into SG> account timezone and daylight savings. For example, timestamp: SG> 1308666350 should be converted to: 2011/06/21 16:25:50, assuming GMT+1 SG> timezone in the winter (GMT+2 in the summer). I would like this SG> conversion to work both during the summer and the winter, meaning that SG> if I try to convert the above timezone during the winter time, it SG> should work as well. So, I would like for the conversion to work SG> similarly to: date -d @1308666350 +%Y/%m/%d\ %H:%M:%S . Is this SG> something possible?

You need to use something like: http://wiki.lazarus.freepascal.org/PascalTZ

Best regards, José