Date object from parsed json to input value [closed]

I am console.log() this:

console.log(value['startDate']);

and getting this:

enter image description here

I want to convert it in my jQuery method so I can input that value here:

enter image description here

I am quite new with jQuery and JavaScript in general so any help will be appreciated.

Answer

The <input type="date"> has a property called valueAsNumber to which you can assign a timestamp like the one in your object.

The input will then do the heavy lifting for you and set the corresponding date.

const input = document.querySelector('input');

const value = {
  startDate: {
    offset: 0,
    timestamp: 1604966400,
    timezone: {}
  }
};

// This is where the magic happens.
input.valueAsNumber = value.startDate.timestamp;
<input type="date">