1. Marcin Jurkowski
  2. PowerBuilder
  3. Tuesday, 20 October 2020 08:53 AM UTC

Hi,

Would anyone know how to convert Unix Timestamp to DateTime in PowerBuilder?
This needs to be done on an object without database connection.

P.S. Appeon, it think it would be nice to have this functionality (Timestamp to DateTime and DateTime to Timestamp converters) built in into PB (if it's not there) for consuming REST APIs.

Regards,
Marcin

Accepted Answer
René Ullrich Accepted Answer Pending Moderation
  1. Tuesday, 20 October 2020 09:16 AM UTC
  2. PowerBuilder
  3. # Permalink

Hi Marcin,

AFAIK the Unix Timestamp is the number of seconds after 1970-01-01.

In PFC you can find the function of_RelativeDatetime in DateTime service (pfc_n_cst_datetime). It should do what you want:

of_RelativeDatetime (DateTime (Date (1970, 1, 1)), ll_unixtimestamp)

 

If you don't have PFC: The code is available for free and it is easy to extract.

HTH,

René

Comment
  1. Marcin Jurkowski
  2. Tuesday, 20 October 2020 09:51 AM UTC
Hi René,

Thank you.

I managed to extract the PFC code for of_RelativeDatetime from another project and use it in mine.

Regards,

Marcin
  1. Helpful
There are no comments made yet.


There are replies in this question but you are not allowed to view the replies from this question.