Date Parse in Backend

Hello!

I’m needing to Parse a date from an API, however I need to do it in the backend.
Does anyone have a method for this? An example of the date is: 20210302

Any ideas would be really appreciated!

Cheers,
Rory

Do you mean you want to parse the date in the Plugin builder? Or is this some thing that you’re getting from an API call in the app and you want to turn it into a usable date before you use it in another step of a workflow?

Hey!

Your second point exactly. I’m getting this data from an API call in a scheduled backend workflow. I want to then parse it in the workflow to then use that info in another step.

The way that I would do it, which is probably not the only way, would be to use the JavaScript tool box plug-in and use a workflow action. Using the results of the API returned data, I would use moment JS or Luckson JS to parse that time I am imagining you probably want that as a string and not a date object so it might be something like this in your JavaScript. Be sure to return a date.

var d = new Date(Results from Step 1’s api call * 1000)
d.setUTCSeconds(utcSeconds);
d;

I just realized that that’s not what you need. I was looking at that as if it was a epoch time. You need a text for matter. I believe I’ve seen a plug-in that would do this for you I’ll have to look around. In the meantime hopefully somebody else can be helpful!

A quick search revealed the following plug-in. It may be helpful but not exactly what you’re looking for.