For instance, we write:
const date = new Date('Wed Dec 21 2022 00:00:00 GMT+0000 (GMT)') const time = new Date('Sun Dec 31 2000 03:00:00 GMT+0000 (GMT)') const datetime = new Date(date.getFullYear(), date.getMonth(), date.getDate(), time.getHours(), time.getMinutes(), time.getSeconds()); console.log(datetime)
to combine the
We get the year, month, and day from
And then we get the hours, minutes, and seconds with
As a result, we get that
'Tue Dec 20 2022 19:00:00 GMT-0800 (Pacific Standard Time) '.