Tuesday, June 4, 2024
 Popular · Latest · Hot · Upcoming
23
rated 0 times [  30] [ 7]  / answers: 1 / hits: 18532  / 9 Years ago, thu, december 3, 2015, 12:00:00
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 time on an existing date. however the above doe is not setting the time in the date. The time always comes as ...00:00:...



Any idea?



Thanks,


More From » datetime

 Answers
15

You have to convert your moment to a Date, and assign that Date object to your end variable:



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

[#64176] Wednesday, December 2, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ervindouglasm

Total Points: 451
Total Questions: 103
Total Answers: 102

Location: Turkmenistan
Member since Thu, Dec 1, 2022
2 Years ago
;