1

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.

joopeerr
  • 183
  • 1
  • 1
  • 12

1 Answers1

0

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">
Emiel Zuurbier
  • 19,095
  • 3
  • 17
  • 32