getDate() is returning a strange value

I have a date field on my form set to 08/01/2018. The following code return 31 as the result of getDate() where it should return 1. Changing the date to 08/02/2018 returns 1 when it should be 2 etc. It’s almost as if the functionality of getDate() has changed to mirror getMonth(); except in offline testing that isn’t the case and works as expected.

function futureDate (entryDate) {
var entry = new Date(entryDate);
var result = entry.getDate();
return result;

Hi Nathan,

I wonder if you are using a date-and-time field instead of a date field.

Since I noticed that depending on the time zone you set up on kintone’s user account and the date-and-time field value, the argument that you pass from a date-and-time field after creating a Date object can be changed like in your case. Therefore, I would suggest using a date field if you are using date-and-time field now or try Moment.js to format the value of a date-and-time field instead of creating with a new Date object.

Here is the info about Moment.js.

▼ Moment.js - customize date formats

Regarding the different value in the test and production environment, if I put the same value on a date-and-time field, I got the same result.  Here is how I went to the test environment for your reference.

▼ Previewing an App


Hi Junko,

Thanks for your help. I was able to get Moment.js to work and correctly format the date.

Thanks also for the preview tip!