extract UNIX time from field in array and use that to determine time

Options

Hi.

I'm experiencing an interesting challenge.

I have an API calling data that has one of the fields returning a string that has a combination of 5 random letters and 16 digits representing a UNIX time.

Some of the entries are repeated but the UNIX time itself is unique even where there is a repeated entry. However the random string makes the field unique meaning if I use the field, in the Unique filter, it returns all the values.

tqfyd1688578975095

tsdty1688578975095

abcde1688578975095

All the above are the same but the random string of letters at the beginning makes the field unique.

Is there a way to use the unique filter but return entries in the array that are unique from extracting the bit of the string that will show they are repeated? Maybe something like the below?

Answers

  • Lefteris - blupry.com
    Options

    Hello @enyarick,

    Considering that the letters will always be before the numbers, the easiest implementation is to just use the "ltrim" filter, where in the mask option you will include the whole alphabet, as a string the one letter next to the other.

    A sample implementation is displayed below:

    Every entry should be parsed through this filter (replace "justastring" with your entry).

    The filter should look something like this:

    Note that on the Mask option you need to include the whole alphabet.

    Other than that, you could also you a regex (such as "/\d+$/") that would match to the first number, and everything before that should be ignored.

  • enyarick
    enyarick Member
    Options

    Nice! This needs a test.

    I was able to extract the section but it didn't pick up as a date.

    I'll try again.

  • Lefteris - blupry.com
    Options

    Hello again @enyarick,

    What you need is the format_timestamp filter, and the correct format alongside the preferred Timezone.

    For example check this:

    And more specifically inside the filter configuration:


    In this case I will convert one of the timestamps you mentioned above to an actual date following the format that you see. This is the response I would get:

    Xano uses php date formats, so if you need to create a different format than the one shown on my example you should take into consideration this resource: https://www.php.net/manual/en/datetime.format.php