Skip to main content

convert unix time string

Hi,

I have created an IDEAScript that searches through an external folder for certain parts of filenames.
The names of the log messages are always in format

info1_info2_info3.log

In other words, i created a IDEAScript Macro that splits the filnames by separator _ to determine the values and write them to a CSV file.

One of the areas e.g. info1 contains allways a UNIX timestamp in seconds starting from 01/01/1970 00:00:00.

Within IDEA there are the functions @dotj or @jtod, which converts this numbers into a real Date (if you add the seconds from 01.01.1900 to 01.01.1970).
It seems unnecessary and cumbersome to me to write the filename separations into a CSV, then import this file to IDEA, add a field with the converted Date via @dotj and export this file into csv via IDEA into an csv again.

Hence the question:
Is it possible to convert this value(UNIXTimestamp) in a human-readable format e.g. Example dd.mm.yyyyThh:mm:ss "outside" from imported Databases via IDEAScript?

I have tryed endless variants such as Example DateAdd or CDate but without success.

In the end I would like to import the log files into IDEA. However, the import should be limited to a certain period, which is determined on the basis of the UNIXTime conversion.

Thx for Help,
Torsten

Brian Element Thu, 03/27/2025 - 19:19

Hi Torsten,

There probably is, but looking around there is 10 digit and 13 digit unix codes.  Can you give some examples of the unix codes so that I have something to work with.

Thanks

Brian

klmi Fri, 03/28/2025 - 04:13

If the timestamp is 13 digits long I guess it will end with "000" and must be divided by 1000 at first.