Convert UNIX milliseconds in array list to UNIX seconds


I need to bring a list of array data from an external API into Bubble. The external API response provides timestamps in UNIX milliseconds but Bubble only recognizes timestamps in UNIX seconds so a conversion is needed. The API response appears in this format:

id: 1
created_at: 1654006395850
description: “Description 1”
id: 2
created_at: 1653875682508
description: “Description 2”

I have been using the secondsToDate plugin in other sections of the app. Since Bubble only recognizes UNIX timestamp in seconds, and the external API provides timestamps in UNIX milliseconds, I use the plugin to convert to UNIX seconds (which Bubble prefers) by dividing by 1,000 (hint: I pull the datetime fields into Bubble as a number to make it possible to divide by 1,000).

I’ve realized that when I use the plugin on API responses where the datetime field isn’t nested, the plugin works just fine. But when the datetime field is nested within an object in the response (as is the case with created_at above), the plugin doesn’t work. In such situations, when I divide by 1,000, it doesn’t display anything at all on the preview page. But when I don’t divide by 1,000, it displays on the preview page like the picture below:


Any assistance on how to deal with this problem will be greatly appreciated, even if it requires another solution other than the plugin I’m currently using.

so what i have experienced is the other way around. i recieve a UNIX code in seconds which bubble places in the year 1970 (start of UNIX time).

what i found worked is this, it maybe new. but you can set the date on the JSON as date(UNIX).

this correctly placed the date without having to do anything fancy. i found this after about and hour of trying to make it harder…

If it’s because you’re using Xano (cause i know it give unix-milli), i personaly decided to use their “format_timestamp” filter with format being “c” to directly get a readable format by human and by bubble.

So it means that in Xano, when your wanna return a data set, before returning it, you have to do a foreach loop to format each of your timestamp fields ?

Actually no, just send your timestamp from Xano, in your API Connector in bubble, choose “Date” (not date unix) and it’ll work :wink:

that’s what i’ve figured out …
Thanks :slight_smile: