Forum Documentation Showcase Pricing Learn more

Convert unix time to date field

I’m using an API workflow to capture a Stripe event, however Stripe uses unix time for their date fields. Could the date field be updated to support unix time format?

Otherwise is there a way for me to convert the unix time to the correct date format?

That is a date. If you set the field to date in API Connector > Returned Values window, it should turn into what you are expecting.

I know it’s a date.
I have set that field type to be “date” when detecting the request data.

However when the workflow is triggered the date value is not being stored.
I assumed it’s because it’s trying to write “1538199710” into the field and it doesn’t recognise it.

Anyway I managed to find a plugin (secondsToDate) to do the conversion.

Could be bugged. I’ve not tried that. But docs say that Unix time stamps will come across as dates. If it doesn’t, file a support ticket/bug report. I just did that on date ranges (which aren’t even documented). You’re one up on me!

Stripe returns seconds and Bubble expects milliseconds.

Some discussion here with some workarounds:

Another workaround which is handy if using API workflows: a plugin that sends the seconds to MathJS API and returns the result as date form.

Yes, this worked for me:

Using the method suggested to set current time set to 1/1/1970 +seconds works. However I have to do this in a number of places. Is there a better way to reuse this logic rather than reimplementing it everywhere?

1 Like

Am I setting this up wrong?

How come I can’t access the date in step 2 after taking a string (unix timestamp) and converting it to a date in an api workflow?