If you need to change the standard date format received via scripts, you can use either of these two options to change the date format.
How to Format Standard and Custom Date Fields via Scripts
There may be times when you want/need to format a date field within Infoplus. By default, date fields are returned in the following format: (Year-Month-DayHour-Minute-Second) 2019-11-02T00:00:00.000Z. While this is useful for some purposes, there may be times you want to use a short or custom date format.
Infoplus Support can help with general questions about how scripting works. For help with a specific script or its outputs, you will need to submit a Pro Services request for paid support. Pro Service request form can be found here.
We have two simple solutions you can use to format your dates any way you want.
The first method is to use .toLocaleDateString
(new Date()).toLocaleDateString('en-US');
Simply place the date you want to format in the open parentheses of the new Date object.
The second method is to use .getDate(), .getMonth() and .getYear() to create your own custom format.
Be mindful of using .getDate vs .getDay
Here are more date methods that can be used:
Here are more date methods that can be used:
Method | Description |
---|---|
getFullYear() | Get the year as a four digit number (yyyy) |
getMonth() | Get the month as a number (0-11) |
getDate() | Get the day as a number (1-31) |
getHours() | Get the hour (0-23) |
getMinutes() | Get the minute (0-59) |
getSeconds() | Get the second (0-59) |
getMilliseconds() | Get the millisecond (0-999) |
getTime() | Get the time (milliseconds since January 1, 1970) |
getDay() | Get the weekday as a number (0-6) |
Date.now() | Get the time. ECMAScript 5. |