I have
var timestamp: Longint;
timestamp := Round((Now() - 25569.0 {Unix start date in Delphi terms} ) * 86400);
which I am using as a primary key in some MySql stuff.
But I would also like to format the date/time, like PHP's date() function does.
Does anyone have a code snippet or URL?
Unix time is a way of representing a timestamp by representing the time as the number of seconds since January 1st, 1970 at 00:00:00 UTC. One of the primary benefits of using Unix time is that it can be represented as an integer making it easier to parse and use across different systems.
You are looking for
function DateTimeToUnix(const AValue: TDateTime): Int64;
and
function UnixToDateTime(const AValue: Int64): TDateTime;
functions from DateUtils.pas
TDateTime value can be formatted by FormatDateTime function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With