Often enough API’s return timestamps to represent certain date and times. I found a very cool trick using Bubble’s built-in Date (UNIX) that allows you to automatically convert the timestamp to a date.
Bubble recognizes them as a number so you’ll need to modify the response manually.
Unfortunately, @nocodeventure, I’ve found this type doesn’t actually render correctly (unless I’m doing something wrong) when the date (UNIX) typed field is then displayed in an RG. For example, this is a configuration I’ve made for a Get API call:
But THIS is what I get when I display the “created_at” field’s value in a Text element. The right-hand value is the actual value extracted to UNIX, which converts just fine.
Any tips on getting the value to ACTUALLY display correctly? I’m sure I’m just missing something…
Thanks for that, @cmarchan. I was using that feature, but I’m trying to figure out why Bubble’s Date (UNIX) type doesn’t render the same thing as the Unix Extract. For example, using that Extract from date feature renders a legitimate UNIX Epoch timestamp that is accurate.
Editor:
App (Date (UNIX) on left, Unix Extract on Right):
The first stamp renders as follows when plugged in to the Epoch Converter:
This is because the Date (unix) gives you seconds where as Bubble.io extract Unix gives you milliseconds.
Im not sure why the inconstancy but as @jared.gibb said you then have to multiply by 1000 to put the Date(unix) into milliseconds.
I also use the Epoch converter and you can see there it says timestamp in Seconds because it is realizing it is getting seconds by looking at the length of the number.
Just to add on to this topic. Stripe returns the unix timestamps in seconds, hence why this method works. For other api’s they might return MS, in that case this won’t work.
Any idea why subscription schedule update call gives error 400 says bad request when i send date time to unix timestamp in miliseconds? or seconds. or how can i convert bubble datetime to epoch timestamp?
yeah m using that but stripe api gives error as a bad request. that timestamp is in miliseconds sometime it takes and sometimes throws error saying value should be lesser than 9999999999
Try displaying that same value in a text element to see what it is sending to Stripe. Like right now the unix time is 1694620794 (in seconds) which would be under that error they are giving…
i am trying to convert datetime to unix timestamp that gives miliseconds which is 13 digit. how can i convert them to 10 digits
when i am trying to devide that number by 1000 it givves decimal points i just want to remove that. format as number will return text so i cant use it. and floor and ceiling returns 0
Screenshot the number you’re working with. :floor and :ceiling will bring it to the closet whole number but shouldn’t 0 it out. Or just add :rounded to 0 instead