Extracting timestamp from brackets

I need to get the UNIX timestamp value wrapped in brackets like below returned from the Xero API and post it as a date. Is this possible with the split function (or any other wappler functions)?

“UpdatedDateUTC”: “/Date(1518685950940+0000)/”,

This is the line of the repeat I need to extract it from/to

apiInvoices.data.Invoices[$index].UpdatedDateUTC

This is an example from Stack Overflow, I’ve tried adjusting split to similar syntax but can’t get it to work…

string input = "User name (sales)";
string output = input.Split('(', ')')[1];

Thanks!

Hi, please try with:

UpdatedDateUTC.split('(')[1].split(')')[0]

The first split will return everything after the ( and the second one everything before ) - so exactly what you need.

Thanks Teodor,

I get an error back from that…

apiInvoices.data.Invoices[$index].UpdatedDateUTC.split('(')[1].split(')')[0]

Gives: “Too few arguments to function lib\core\formatter_split(), 1 passed and exactly 2 expected”

Going with:

apiInvoices.data.Invoices[$index].UpdatedDateUTC.split('(',')')[1]

gives me: 1580934319157+0000)/

Ah, so that’s in Server Connect - indeed it doesn’t work there. I was playing with the App Connect Formatting options.
If you expect the same result every time you can use the substr option in Server Connect Formatter:

apiInvoices.data.Invoices[$index].UpdatedDateUTC.substr(6, 18)

Great, that works, thanks!

Didn’t think of that, was too focussed on the brackets!

1 Like