Using different date formats from API data

Hi

I’m using the Xero API (via the Zeroqode plugin) in my Bubble project but wondered how people are using and formatting things like the invoice date fields for example?

The Xero API returns the date in a couple of formats (e.g. Either “/Date(1670716800000+0000)/” or “2022-12-11T00:00:00”) but neither of these can be used as a date and formatted as such within Bubble.

Within my project, I want to be able to both display the dates UK format (e.g. “11/22/22”) and also use them to calculate differences between these dates and the current date etc.

Any ideas of the best solution?

Thanks

Richard

Set the data field to datetime when you initialize your api call , then when you call that api from your bubble editor, you can perform all sorts of calculations on that date.

Thanks but I don’t think I can set the data field as I’m using a plugin (Zeroqode Xero plugin) to get the data rather than the API directly.

Unsure how confident you are with the plugins, but you could create a simple plugin that takes the string and converts to a date.

Use an NPM package such as Luxon to do the date conversion - Bubble is then great at formatting dates for you, once the data type is correct :slight_smile:

Thanks. I’m trying to keep things as simple as possible but I think you may be right that I need to use a plugin for the conversions

This topic was automatically closed after 70 days. New replies are no longer allowed.