Subscribe Bookmark RSS Feed

Unix Timestamp to Real Date & time

d_barnett

Community Trekker

Joined:

Nov 30, 2011

I extract data from a database and part of this is a "start time" for a process. The main problem with this is that it is in UNIX format so therefore returns a 10 digit number, I know that the formula for converting this to actual date and time is as follows

( taken from Excel)

=CELL/(60*60*24)+"1/1/1970"

so changing a column in JMP should be straightforward but I can't seem to do it. The (60*60*24) is easy but what format do I have to set the +"1/1/1970" to to make this work?

I have attached a data table that contains some dates from the past 6ish years as an example. My feeling is that this might have been asked before but I can't see anything that relates to it.

Regards


David

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

The UNIX date is the number of seconds since midnight, January 1, 1970.

JMP stores dates as the number of seconds since midnight, January 4, 1904.

So, we just need to add the JMP date value for January 1, 1970 to the Unix date value. You can use the Date DMY() function to do this:

10238_JMPScreenSnapz001.png

-Jeff

-Jeff
6 REPLIES
Craige_Hales

Staff

Joined:

Mar 21, 2013

try 1jan1970 without any quotation marks. 

format( 1jan1970+1445432452, "mdy" )

"10/21/2015"

(That's today, for future reference.  I got Epoch Converter - Unix Timestamp Converter to give me the Unix time for today: 1445432452 )


adding 1jan1970 works because the Unix time for 1jan1970 is zero.  And because JMP and Unix are both counting in seconds.


Be careful, I've seen some discussion about when the Unix epoch really began: Unix time - Wikipedia, the free encyclopedia says


The first edition Unix Programmer's Manual dated 3 November 1971 defines the Unix time as "the time since 00:00:00, 1 January 1971, measured in sixtieths of a second".[5]

The User Manual also commented that "the chronologically-minded user will note that 232 sixtieths of a second is only about 2.5 years". Because of this limited range, the epoch was redefined more than once,[citation needed] before the rate was changed to 1 Hz and the epoch was set to its present value of 1 January 1970 00:00:00 UTC. This yielded a range of about 136 years, though with more than half the range in the past (see discussion of signedness above).

Craige
Solution

The UNIX date is the number of seconds since midnight, January 1, 1970.

JMP stores dates as the number of seconds since midnight, January 4, 1904.

So, we just need to add the JMP date value for January 1, 1970 to the Unix date value. You can use the Date DMY() function to do this:

10238_JMPScreenSnapz001.png

-Jeff

-Jeff
d_barnett

Community Trekker

Joined:

Nov 30, 2011

Jeff,

I had noticed January 4, 1904 popping out a number of times and I thought that it was some formatting or calculation error that I had made, this only added to my confusion why I couldn't get this date conversion to work.

thanks for your help

David

billw_jmp

Staff

Joined:

Jul 2, 2014

Just an add to Jeff's post.  When I used his formula I got back the number of seconds.  I added the MDYHMS format to the formula to get date and time

10241_pastedImage_0.png

Bill

billw_jmp

Staff

Joined:

Jul 2, 2014

Another add - talked with Jeff offline and he made a very good point.  Don't use the character string "MDYHMS" if you want to do some math with your time stamps.   Use Column Info to format your new times as continuous data.

10242_pastedImage_0.png

d_barnett

Community Trekker

Joined:

Nov 30, 2011

Jeff/ Bill,

I noticed that it was in seconds as well but I used the formatting available to turn it into 'proper' time.

Thanks again.

David