cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
lala
Level IX

How do use JSL to convert seconds since January 1, 1970 to HH:MM:SS days, months and years?

Hello!

 

 

1652335737

to

2022/05/12 14:08:57

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How do use JSL to convert seconds since January 1, 1970 to HH:MM:SS days, months and years?

The formula to make the modification is:

1652335737 + Informat( "01/01/1970", "mm/dd/yyyy" ) + In Hours( 8 )

The addition of the 8 hours in the calculation, is that apparently the start time for the 01/01/1970 is 08:00:00

This JSL displays the new calculated value from the formula

Show( Format( 1652335737 + Informat( "01/01/1970", "mm/dd/yyyy" ) + In Hours( 8 ), "yyyy-mm-ddThh:mm:ss" ) );
Format(1652335737 + Informat("01/01/1970", "mm/dd/yyyy") + In Hours(8), "yyyy-mm-ddThh:mm:ss") = "2022-05-12T14:08:57";
Jim

View solution in original post

5 REPLIES 5
lala
Level IX

Re: How do use JSL to convert seconds since January 1, 1970 to HH:MM:SS days, months and years?

2022-05-13_11-45-53.png

lala
Level IX

Re: How do use JSL to convert seconds since January 1, 1970 to HH:MM:SS days, months and years?

OK

2022-05-13_11-55-40.png

txnelson
Super User

Re: How do use JSL to convert seconds since January 1, 1970 to HH:MM:SS days, months and years?

The formula to make the modification is:

1652335737 + Informat( "01/01/1970", "mm/dd/yyyy" ) + In Hours( 8 )

The addition of the 8 hours in the calculation, is that apparently the start time for the 01/01/1970 is 08:00:00

This JSL displays the new calculated value from the formula

Show( Format( 1652335737 + Informat( "01/01/1970", "mm/dd/yyyy" ) + In Hours( 8 ), "yyyy-mm-ddThh:mm:ss" ) );
Format(1652335737 + Informat("01/01/1970", "mm/dd/yyyy") + In Hours(8), "yyyy-mm-ddThh:mm:ss") = "2022-05-12T14:08:57";
Jim
UersK
Level III

Re: How do use JSL to convert seconds since January 1, 1970 to HH:MM:SS days, months and years?

How do  reverse this calculation?
For example, calculate the date 20230214 into seconds

 

Thanks!

 

In Days( Informat( Char( 20230214 ) ) -In Hours( 8 ) ) - In Days( 1jan1970 )

??

 

1676304000000

txnelson
Super User

Re: How do use JSL to convert seconds since January 1, 1970 to HH:MM:SS days, months and years?

Names Default To Here( 1 );
date = "20230214";

// The JMP time values are based upon the number of seconds
// since January 1, 1904, therefore the calculation to the 
// number of seconds since then would be
JMPDate = Date MDY( num(substr(date,5,2)), num(substr(date,7,2)), num(substr(date, 1, 4)));
show(JMPDate, format(JMPDate,"m/d/y"));

// To convert this to the number of seconds since January 1, 1970
Jan1970Date = JMPDate - informat("01/01/1970", "m/d/y");
show(Jan1970Date);
Jim

Recommended Articles