How to convert C / unix integer datetime in seconds since 1970 to DateTime in Delphi?

I know how to use python time to convert "1328834615" to a date.

>>> import time >>> time.ctime(1328834615) 'Fri Feb 10 08:43:35 2012' 

How can I do this using Delphi?

+4
source share
1 answer

Try using the UnixToDateTime function, which is part of DateUtils .

 {$APPTYPE CONSOLE} uses DateUtils, SysUtils; Var Dt : TDateTime; begin try Dt := UnixToDateTime(1328834615); //do something Writeln(FormatDateTime('ddd mmm d hh:nn:ss yyyy', Dt)); except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; Readln; end. 
+14
source

Source: https://habr.com/ru/post/1396767/


All Articles