0

我正在尝试使用 PHP 处理Quickbooks My Time imt 文件。imt 文件是纯文本 XML 文件。我已经能够毫无问题地使用 PHP SimpleXML 库,但有一个问题:

My Time XML 文件中日期时间的数字表示是我以前从未见过的:

<object type="TIMEPERIOD" id="z128">
    <attribute name="notes" type="string"></attribute>
    <attribute name="start" type="date">308073428.00000000000000000000</attribute>
    <attribute name="running" type="bool">0</attribute>
    <attribute name="duration" type="double">3600</attribute>
    <attribute name="datesubmitted" type="date">310526237.59616601467132568359</attribute>
    <relationship name="activity" type="1/1" destination="ACTIVITY" idrefs="z130"></relationship>
</object>

您可以看到attritube[@name='start']的值为:

308073428.00000000000000000000

这不是基于 Excel 的存储方法 308,073,428 自 1900 年 1 月 00 日以来的天数太多,也不是 Unix 纪元。

所以,我的问题是,有没有人见过这种类型的日期时间表示?

4

1 回答 1

0

看起来 Quickbooks My Time imt 正在使用某些版本的 OS X Core Data 来存储应用程序信息。经过一段时间的挖掘,我发现 Core Data/Cocoa 使用 2000-01-01 00:00:00 作为他们 epoch 的开始时间。因此,只需将秒数添加到 epoch 即可获得正确的日期:

<?php
  $start_as_int = (int) $node;
  $dt = new DateTime('2010-01-01 00:00:00');
  $dt->add(new DateInterval('PT'.$start_as_int.'S'));
  print $dt->format('m/d/Y');
?>

这足以获得正确的日期,但是,我仍然不确定如何处理有效时间小数点右侧的值。

于 2011-01-06T05:47:38.380 回答