John-S Pretorius
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
Can they provide the time as it is stored, number of seconds?
mlmcc
mlmcc
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
//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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you James, I replaced my process with your method.
You're welcome. Glad I could help.
James
James
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.