donglianer5064 2012-09-14 07:07
浏览 54
已采纳

PHP转换WIM日期格式

I am writing a wrapper library for WIM files (long story), but I have been having difficulty with the dates encoded in it. The format is:

[creationtime] => Array
                        (
                            [highpart] => 0x01CA0446
                            [lowpart] => 0x8E44DCAF
                        )

This format is inside the WIM file XML. I have tried every date decoding technique I can think of! Any ideas would be much appreciated. The only things I have to go on are things related to Long Integers and WIN32 DateTime... But no luck so far.

  • 写回答

2条回答 默认 最新

  • douwen1213 2012-09-14 07:27
    关注

    liCreationTime is defined as LARGE_INTEGER in the WIM spec (I downloaded from MS)

    This looked to me like it would be similar (if not the same) as a timestamp returned by QueryPerformanceCounter - which thankfully makes things very simple!

    I did this using a calculator and command line PHP, you'll have to implement the code yourself.

    Take your high and low parts and turn them into a single 64bit value.

    0x01CA04468E44DCAF -> 128920240414579887

    Divide that by 100000000

    1289202404

    Use it as the input to date()

    php -r "var_dump(date('Y-m-d H:i:s', 1289202404));"
    string(19) "2010-11-08 07:46:44"
    

    Edit:

    Or maybe I just got lucky.

    If it is the number of nanoseconds since 1601, as other answers seem to indicate, you can use a slightly different calculation.

    php -r "var_dump(date('Y-m-d H:i:s', (128920240414579887/100000000)-41651963));"
    string(19) "2009-07-14 05:47:21"
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable