Formatting date in SharePoint API REST query result

You are using ShortPoint REST API Connection Type and you would want to format the date returned in a proper readable format for end users instead of showing it in ISO format.

For demo in this article, we have used Modified column but this article is not limited to Modified column only, you can use this solution for any date column you want.

Step 1

Connect to SharePoint REST API

Add ShortPoint to your page and use REST API connection type in your connect tab

To demonstrate in article, we have used Icon lists and ShortPoint and following REST API'Documents')/items?$select=Modified,FileLeafRef

The date we are going to format is Modified column.

Step 2

Format the date result using Map Results feature

Now is the time to do the magic of changing the date format to the way we want. By default, you would see the result like below:

Lets go ahead and enable the Advanced Settings and format the date using custom code:

the code you see in above screenshot is as below:

var moment = shortpoint.base.libs.moment;
data.d.results.forEach(function(item) {
item.Modified = moment(item.Modified).format('LLL');
return data;

Note: LLL is one of the format which will represent date in Month name, day of month, year, time format (Ex. September 4, 1986 8:30 PM).  A few more examples are as follows:

TimeLT8:30 PM
Time with secondsLTS8:30:25 PM
Month numeral, day of month, yearL09/04/1986
Month name, day of month, yearLLSeptember 4, 1986
llSep 4, 1986
Month name, day of month, year, timeLLLSeptember 4, 1986 8:30 PM
lllSep 4, 1986 8:30 PM
Month name, day of month, day of week, year, timeLLLLThursday, September 4, 1986 8:30 PM
llllThu, Sep 4, 1986 8:30 PM

Click here for more examples and detailed explanation on Date and Time Formatting.

Please be ware that since we have used Modified column we have used this line in the code:

item.Modified = moment(item.Modified).format('LLL');

However, if you have any other column to be formatted, please change above line and replace Modified with your own column name. You can also format multiple columns as follows

var moment = shortpoint.base.libs.moment;
data.d.results.forEach(function(item) {
item.DateColumn1 = moment(item.DateColumn1).format('LLL');
item.DateColumn2 = moment(item.DateColumn2).format('LLL');
return data;

Click on connect. You are done!

Here is an animation of steps you need to perform