It is advised to use a different JavaScript date and time library instead, such as Luxon.
Introduction
This article introduces how to use the Moment.js library, listed on the Kintone CDN. It can be used to convert dates into different formats, such "xx days ago".
What is Moment.js?
Moment.js is a JavaScript library used to alter, validate, calculate and display date and time data. The source code and documents can be found on the Moment.js website.
Import Moment.js for the Kintone App
In the JavaScript and CSS Customization settings of the Kintone App, add a link to the Moment.js library listed in the Kintone CDN.
For more information on how to use the libraries in the CDN, refer to the How to Use the CDN article.
Use Moment.js with Kintone
Once the Moment.js library has been imported, it is possible to call the Moment.js methods within Kintone. Here are some examples:
Moment.js makes manipulating date formats very easy.
For more information on how to use the Moment.js library, refer to Moment.js documentation.
Moment.js sample on Kintone
Upload the following code to the JavaScript and CSS Settings of the App, after the Moment.js CDN link.
Click Save and Update App to view the changes in the record list.
This code specifies a field code of a Datetime field in the App, and uses Moment.js to convert the date into a new format. The new format is placed in the record list instead of the original date format.
Finally
Formatting date and time by using only standard JavaScript can be a troublesome task, but using Moment.js can help save a lot of time and effort. Additionally, the Moment Timezone library allows date and time to be changed to a different timezone by JavaScript. For any trouble handling Moment.js on Kintone, please post an issue in the Kintone Developer Program community.