Unix Time


Kindly help me out from below case.

Dim Message_Time As String
Message_Time = “2016-02-27 10:16:01”

I want convert into Unix time.

If you have a look at http://developer.xojo.com/xojo-core-date you’ll see you can create a new Date (you’ll have to parse the SQLDateTime yourself). The property SecondsFrom1970 should give you the unix time.

This will convert your SQL Date/Time format into Unix time:

dim rx as new RegEx
rx.SearchPattern = "\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}"
rx.ReplacementPattern = "Unix Time"

Message_Time = rx.Replace( Message_Time )


if you want the seconds since 1970, you can create new date(1970,1,1,0,0,0) and subtract total seconds from other date.

This is the way I’ve handled it forever on OS X. Apparently, the myth has it that Steve loved his mom and that’s why the 1904 date for the Apple / OS X epoch…

Except Jobs biological mother was born in 1932, making her 31 when he was born, his adoptive mother was born in 1924

Then I’ve no clue as to where the 1904 date came from. That story’s what I’ve always heard when I’ve asked someone at Apple…

However, a dig into Apple history via the way back machine identified this bit from Geoff Duncan:

So, it’s just something that happened - even though the rest of the computing world went with variants of either Dec/31/1969 or Jan/01/1970.

No magic or mystery
It had certain nice properties

FYI… I’m the same age as Steve Jobs would have been… and my late GRANDMOTHER was born in 1903 :slight_smile:

lots of fun rumors about things just like there are conspiracy theories
the truth is sometimes much more boring

rumors are just that rumors, but selections are usually selected for some reason which at the time makes sense (which are usually not related to rumors - definitely not the birth or death of a person, other than Jesus that is)