Unix Timestamp

Kenneth Brody kenbrody at spamcop.net
Sun Dec 29 18:52:17 PST 2013


On 12/26/2013 3:16 PM, Nancy Palmquist wrote:
>
> Has any clever filepro programmer, written a routine to convert a Unix
> Timestamp to a date/time and also to convert a date/time to a Unix
> timestamp.  If it matters, this is running on SCO Openserver, with
> filepro 5.0 or later (can't remember if they had 5.6 or 5.0 right off
> the top of my head.)
>
> I find I am working on a project where one customer tracks by Unix
> timestamp and another tracks by Date/Time and they need to exchange data.
>
> I understand the Unix timestamp meaning but did not want to reinvent the
> programming to translate, if someone has worked it out already.

As I recall, "Unix time" is the number of seconds since 00:00:00 UTC 
1-Jan-1970.  I do not know if it takes leap seconds into account.

Assuming leap seconds are not involved...

I believe that this *untested* pseudo-code would do it:

     Epoch(10,mdyy/) = "01/01/1970"
     Date(10,mdyy/) = Epoch + INT(UnixTime / "86400")
     Time(8,TIME) = MOD(UnixTime,"86400") / "3600"

(There are 86,400 seconds in a day and 3,600 seconds in an hour.)

Note, however, that this results in a UTC time, and is not adjusted for the 
current timezone.  This can be done by adding/subtracting the appropriate 
number of seconds from the original UnixTime.

-- 
Kenneth Brody


More information about the Filepro-list mailing list