Ask Your Question
0

In Delphi, what is the method for formatting a Unix timestamp?

asked 2023-01-24 11:00:00 +0000

djk gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-10-18 14:00:00 +0000

david gravatar image

The FormatDateTime function can be used to format a Unix timestamp in Delphi.

Here is an example:

var
  UnixTimeStamp: Int64;
begin
  UnixTimeStamp := UnixToDateTime(1625072399); // Convert Unix timestamp to Delphi TDateTime
  ShowMessage(FormatDateTime('dd/mm/yyyy hh:nn:ss', UnixTimeStamp)); // Format TDateTime as a string
end;

In this example, the UnixToDateTime function is used to convert the Unix timestamp to a Delphi TDateTime value, which can then be formatted as a string using the FormatDateTime function. The format string 'dd/mm/yyyy hh:nn:ss' represents the desired output format of the timestamp.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-01-24 11:00:00 +0000

Seen: 11 times

Last updated: Oct 18 '22