Link to home
Start Free TrialLog in
Avatar of John-S Pretorius
John-S PretoriusFlag for United States of America

asked on

Convert UNIX string(memo) time to local time

I'm working with a UNIX string (memo) type time : 2020-06-02T11:22:58.930Z and looking for a way to convert this to local time (EST) : 6/2/2020 07:22:58:930 in Crystal Reports
Avatar of Dr. Klahn
Dr. Klahn

This is not a complex problem but it is tedious due to the necessity of factoring in the many changes over the years which have occurred relating to when DST takes effect.

I don't suppose you can have the program generating the string on the unix system generate in the desired format?  This would be a simple fix and the unix time string generator is extremely flexible.
Can they provide the time as it is stored, number of seconds?

mlmcc
Avatar of John-S Pretorius

ASKER

Thank you all for responding, I ended up figuring it out by:

//Step 1 remove the Z at the end as per the data from the Unix timestamp  2020-05-26T09:56:18.222Z
left({recognitions1.date_time_str},len({recognitions1.date_time_str})-1)
//Step 2 process into a datetime format
CDateTime(CDate(Left((left({recognitions1.date_time_str},len({recognitions1.date_time_str})-1)), 10)), CTime(Mid((left({recognitions1.date_time_str},len({recognitions1.date_time_str})-1)), 12, 8)));  
//Step 3 shift it to EST
ShiftDateTime ({@UNIX Timestamp 2}, "UTC,0,UTC", "EST,240,EST")

Result: 2020-05-26T09:56:18.222Z = 5/26/2020 5:56:18AM
ASKER CERTIFIED SOLUTION
Avatar of James0628
James0628

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you James, I replaced my process with your method.
 You're welcome.  Glad I could help.

 James