1

我正在尝试从十六进制序列中提取时间戳数据,并且缩小了隐藏时间戳的十六进制数据

我发现两个日期相差大约两分钟

(2012-12-01 06:00:55 -0700)
A4  01  1B  FE  36  05  88  23  E4  40  

(2012-12-01 06:02:56 -0700)
A4  01  EF  F9  AF  10  88  23  E4  40  

(2012-12-01 06:00:49 -0700)
A4  01  67  5B  A5  04  88  23  E4  40  

(2012-12-02 06:00:47 -0700)
A4  01  D6  CF  74  04  A8  23  E4  40  

更多时间戳

A4  01  90  A1  B2  03  C8  2E  E4  40
A4  01  22  2D  E3  03  C8  2E  E4  40  
 -0800 
E0  01  FF  15  82  03  C8  2E  E4  40

我很确定,根据我能够取消成为日期的其他一些数据,它使用的是小端编码

但这是我能做到的。我正在使用这个网站http://fmdiff.com/fm/timestamp.html将已知时间戳转换为一些常见格式,但我只是没有看到它。

是否有任何其他格式(可能在 .net 中)我可以尝试使用此信息?


解决了,谢谢@Markus

这是转换(LE)十六进制的代码

#include <Debug.au3>
#include <Date.au3>

_DebugSetup("Debug")

Func GetExcelTimestamp($dec)
   $excel_time = Dec($dec,3)
   $timeinms = ($excel_time-25569)*24*3600*1000
   $sTime = _DateAdd("s", Int($timeinms / 1000), "1970/01/01 00:00:00")

   _DebugOut($dec & " - " & $sTime)
   Return $sTime
EndFunc   ;==>GetExcelTimeDate


GetExcelTimestamp("40E423880536FE1B")
GetExcelTimestamp("40E4238810AFF9EF")
GetExcelTimestamp("40E4238804A55B67")
GetExcelTimestamp("40E423A80474CFD6")
4

1 回答 1

3

下面是读取日期的 Java 代码(解释如下):

//-------------------------------------------------------------------------------
// Convert from hex to usable date value

long temp = 0x40E423880536FE1BL; // Decode 64-bit little endian (backwards) hex
//long temp = 0x40E4238810AFF9EFL; // example 2
//long temp = 0x40E4238804A55B67L; // example 3
//long temp = 0x40E423A80474CFD6L; // example 4

double excel_time = Double.longBitsToDouble(temp); // days since 1/1/1900

//-------------------------------------------------------------------------------
// Convert to something that Java can handle and output in correct timezone

long java_time = (long) ((excel_time-25569)*24*3600*1000); // ms since 1/1/1970
Date date = new Date(java_time);

SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss");
dateFormatGmt.setTimeZone(TimeZone.getTimeZone("GMT")); // don't change timezone
System.out.println(dateFormatGmt.format(date));

日期存储为自 1900 年 1 月 1 日以来的天数(Excel 存储它们的方式),如您正确猜测的那样,从小端格式的双精度浮点转换为十六进制。您在开头包含的A4 01可能不是日期的一部分。

您的日期存储在您发布的时区 (GMT-7) 中,而不是 UTC。

笔记:

如果它是某种其他浮点格式,例如 80 位扩展格式,它可能是数字的A4 01 一部分。但鉴于你的 4 个例子都是一样的,我宁愿认为不是。

于 2013-03-06T02:18:01.133 回答