Converting seconds to real date/time

Hi - I’m pretty new to Xojo, so please forgive if this is a dumb question. I’m reading a SQLite data base that contains several “date” fields that I need to work with. The developer of the DB tells me that these fields are double precision integers and contain the number of seconds from January 1, 1970. Ughhh…

Is there something built into Xojo that does this type of conversion? I need the date as mm/dd/yyyy hh/mm/ss, not some horrible number like what is stored in this DB!

Thanks, Jim

Many thanks! I will give that code a try.

Xojo has a built in SecondsFrom1970 function in its date class.


Dim d as New Xojo.Core.Date(YOURSECONDSFROM1970,Xojo.Core.TimeZone.Current)

will create the data object you need where YOURSECONDSFROM1970 is the data from your database.

Now you can then extract all the vital information like, Month, Day, Year etc. from your date object. No need to use some other functions.

You should ask the DB guy what timezone was used… because it matters. It may be that they’re all stored as GMT and that you need to convert to “local” time when displaying them.

Greg, thank you for pointing that out.

For us that are starting, a good practice will be to always store the information in GMT, I guess.

Folks, I went with Mr. Ogden’s approach which was, by far the easiest. Worked very well but it deducted seven hours from my times. Hmmm… I’m on the west coast - seven hours from GMT. I’m a ham radio operator and knew that the times in the DB were already in GMT so I did some reading of the documentation, added a TimeZone command, and bada bing, bada boom - perfect time conversion.

Greg - I saw your post after I figured things out. And you sure were in the right track with that GMT issue!

So, issue solved, I’m a happy camper.

Thanks / 73 (ham-speak for regards and see ya later)