Time.js a set time for an existing date does not set the time correctly

let end: Date = new Date(); let h: string = "13"; let m: string = "20"; moment(end).set({ hour: parseInt(h, 10), minute: parseInt(m, 10) }); 

I am trying to set the time to an existing date. however, the doe described above does not set the time in a date. Time always comes like ... 00:00: ...

Any idea?

Thanks,

+7
javascript datetime typescript momentjs
source share
1 answer

You need to convert your moment to Date and assign this Date object to your end variable:

 end = moment(end) .set({ hour: parseInt(h, 10), minute: parseInt(m, 10) }) .toDate(); 
+14
source share

All Articles