Question

I'm attempting to process Quickbooks My Time imt files using PHP. The imt file is a plaintext XML file. I've been able to use the PHP SimpleXML library with no issues but one:

The numeric representations of datetime in the My Time XML files is something I've never seen before:

<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>

You can see that attritube[@name='start'] has a value of:

308073428.00000000000000000000

This is not Excel based method of storage 308,073,428 is too many days since 1900-01-00 and it isn't Unix Epoch either.

So, my question is, has anyone ever seen this type of datetime representation?

Was it helpful?

Solution

It looks like Quickbooks My Time imt is using some version of OS X Core Data to store the application information. After digging around for awhile, I found that Core Data/Cocoa uses 2000-01-01 00:00:00 as the start time for their epoch. Therefore, it's simply a matter of adding the seconds to the epoch to get the correct date:

<?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');
?>

This is good enough to get the correct date, however, I'm still not certain how to process the values to the right of the decimal point for a valid time.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top