How to change the format of an array

I have an array with values ​​and I have mapped all the dates (they are in timestamp format) and now I have all the dates in an array. So how do I change the format (DD/MM/YYYY) of all the dates in that array?

1 Like

Welcome to the Make community!

You should use the formatDate function before you aggregate the values into an array.

According to the Tokens you can use to format a date variable, you can use DD/MM/YYYY.

e.g.:

{{ formatDate(now; "DD/MM/YYYY") }}

For more information, see Date Format links below.

Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I found these useful when I was learning Make, and hope they might benefit you too —

Getting Started

Help Centre Basics

Articles & Videos

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.



The problem is that I receive those dates in an array already and I need to modify the format of those dates

When you see ARRAY, think ITERATOR.

Then,

Aggregators

Every result (item/record) from iterator/list/search/match modules will output a bundle. This can result in multiple bundles, which then trigger multiple operations in future modules (one operation per bundle). To “combine” multiple bundles into a single variable, you’ll need to use an aggregator of some sort.

Aggregators are modules that accumulate multiple bundles into one single bundle. An example of a commonly-used aggregator module is the Array aggregator module. The next popular aggregator is the Text Aggregator which is very flexible and can apply to many use-cases like building of JSON, CSV, HTML.

There are other types of aggregator modules, click the below links to find out more:

So, to answer your question, you probably need an Iterator, then Set Variable, before an Array Aggregator.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

Thanks @samliew for your support I really appreciate. But now I have a weird problem: I put the current time in timestamp format and when I use formatDate( to get the current date with this DD/MM/YYYY format, I get a date from 1970. Why am I not getting the current date?


image

@Clof_Company, You might have to parseDate() first and then formatDate(). use parseDate(date;x) to parse unix timestamp. See :

1 Like

Hi @Clof_Company

You can use formatDate() function inside a text aggregator. First you will need to iterate the array.

Regards
Msquare Automation - Platinum partner of Make
@Msquare_Automation

1 Like