Input date with a button click

This sample inserts today's date into a Date field of your App with a click of a button.

To use this sample code, you will need a Date field and a Blank Space field in your kintone App.
A button will be displayed on the Blank Space field, when you create a new record or edit an existing record. 

Sample Image


Sample Code

// A button will be placed on the Blank Space field
// Click the button to add today's date into the date field

(function() {
    "use strict";
    var DATE = 'mydate'; // field code of date field
    var SPACE = 'myspace'; // element ID of Blank Space field (this is where the button will be displayed)['', ''], function(event) {
        var btn = document.createElement('button');
        btn.textContent = "Input Today's Date";;

        btn.onclick = function() {
            var date = new Date();
            var today = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();

            var rec =;
            rec.record[DATE].value = today;
        return event;


Make sure to match the Field code / Element ID of your fields, with the Field code / Element ID written in the code.


Refer to the Tutorial page, on how to add scripts to your app.

Was this article helpful?
0 out of 0 found this helpful
Please sign in to leave a comment.