Discussion:
Timestamp Conversion, PHP
(too old to reply)
KermodeBear
2006-02-02 00:10:42 UTC
Permalink
Greetings all,

I'm coming to this group as it seems to be one of the very few dBase
groups on Google that has any activity. If there would be a better
place for me to ask my question, please let me know.

Background:
I need to be able to use PHP to read dBase files. Currently, the state
of PHP's native dbase functions is pretty grim; Only a few field types
are supported and if a file contains an un-supported field type then
you aren't able to open the file at all (Well, that was after I
submitted a bug report; Previously, dBase files with a timestamp field
would cause memory corruption and segfaults, hooray!) Hence, I am
writing my own code for reading dBase files.

Problem:
I am having problems with the timestamp field. I need to be able to
read the timestamp field but I am having difficulty with it and would
like some guidance.
From what documentation I can find about the dBase file format, the
format of a timestamp field is two unsigned long integers.

The first integer is the number of days since Jan 1, 4713 BC. Does this
include leap years? Can anyone point me to examples (in any language)
of parsing this to a current date? I'm considering using a lot of
modulus math here to get the years down first, then deal with what is
left as days.

The second integer is defined as such:
"Time is hours * 3600000L + minutes * 60000L + Seconds * 1000L"

I *think* that the following (pseudocode) is correct, but if it is not,
please let me know:
timestamp = read unsigned long from file
hours = floor( timestamp / 3600000 );
timestamp = timestamp - ( hours * 3600000 );
minutes = floor( timestamp / 60000 );
timestamp = timestamp - ( minutes * 60000 );
seconds = floor( timestamp / 1000 );

I have been scouring Google et al, but I have been able to find no
information aside from sparse file format specifications. I would
appreciate anything you could provide.

Thanks,
KBear
KermodeBear
2006-02-13 22:30:43 UTC
Permalink
I'm completely unloved. Does anyone know where I can find more
information?

Loading...