获取Unix时间戳
http://www.cnblogs.com/findumars/p/4716753.html
最简单准确一句话
Result:=IntToStr( DateTimeToUnix(now())-28800);
系统自带的函数
{ Unix date conversion support }
function DateTimeToUnix(const AValue: TDateTime; AInputIsUTC: Boolean = True): Int64;
function UnixToDateTime(const AValue: Int64; AReturnUTC: Boolean = True): TDateTime;
还有函数UnixToDateTime,在文件system.DateUtils
c++builder
// 将Java中的日期转换为Delphi中的日期
TDateTime ConvertJavaDateTimeToDelphiDateTime(__int64 Value)
{
return IncMilliSecond(StrToDate("1970-1-1"), Value);
} // 将Delphi中的日期转换为Java中的日期
double ConvertDelphiDateTimeToJavaDateTime(TDateTime ADateTime)
{
return MilliSecondSpan(ADateTime, StrToDate("1970-1-1"));
}
1483927576698
// pc端接收到的数据00 00 01 59 80 f9 e0 7a
// 2017-01-09 02:06:16
byte bta[] = { 0x7a,0xe0,0xf9,0x80,0x59,0x01,0x00,0x00 };
// byte bta[8] = { 0x00,0x00,0x01,0x59,0x80,0xf9,0xe0,0x7a };
double da = *(__int64*)&bta[];
TDateTime dtad;
dtad = ConvertJavaDateTimeToDelphiDateTime(da);
TDateTime dt1;
dt1 = StrToDateTime("2017-01-09 02:06:16");
double jv1;
jv1 = ConvertDelphiDateTimeToJavaDateTime(dt1);
byte bt1[];
memcpy(&bt1[], (byte*)&jv1, ); //check TDateTime dtad1;
dtad1 = ConvertJavaDateTimeToDelphiDateTime(jv1);
//2017-01-10 18:13:24
0x38,0xAD,0x95,0x89,0x59,0x01,0x00,0x00
__int64 jv=1484072004920;
TDateTime dtad;
dtad = ConvertJavaDateTimeToDelphiDateTime(jv);
this->Caption =dtad.DateTimeString();
var
aint: int64;
bs: array [ .. ] of byte;
pb: PByteArray;
begin
aint := ;
pb := @aint;
Move(aint, bs[], );
int64= Trunc(double val);