Avatar

Date Field Format

Miyuki Hamada

I would like to ask how to change the date field format in table to DD/MM/YYYY.

I have checked the posts below.
Change the Date field format
Customize date formats with Moment.js

However I could not adopt these solution because kintone.app.getFieldElements() is not able to be used the field in table.
Is there any ideas to change the date format in table?

Follow 2 followers
0

2 comments

Avatar
Sean Tachibana 1 vote

Hello Miyuki,

Since you cannot acquire the value of the table in kintone.app.getFieldElements(),
you would have to use a different method to change the date format.
It might have to be a customized one by using the DOM operation,
and it also might be necessary to consider operating the table display and non-display.

Using Moment.js and jQuery, I was able to change the date format by using the following code.
※ Assuming that there is only one date field within the table.

jQuery.noConflict();
(function($) {
"use strict";
kintone.events.on("app.record.index.show", function(e) {

$('.recordlist-toggle-subtable-gaia.show').on('click', function() {
var wEle = document.getElementsByClassName("subtable-row-content-gaia")[0];

wEle = wEle.getElementsByClassName("recordlist-cell-gaia recordlist-date-gaia")[0];
console.log(wEle.innerText);

wEle.innerText = moment(wEle.innerText).format('DD/MM/YYYY');
});

});
})(jQuery);

Hopefully, this solves the issue.

Sean

1
Comment actions Permalink
Avatar
Miyuki Hamada 1 vote

Hello Sean,

I understood how to get elements for table field.
Thank you so much for your reply.

Miyuki

1
Comment actions Permalink