1 回答
TA贡献1827条经验 获得超9个赞
解决了
这是我解决问题的最终代码
quizCreate() {
const sems = this.quizData.value;
// convert coming time
const d = new Date(Date.parse(sems.quiz_time)); // my input (2020-10-05T00:00:27.634+07:00)
// add second digits
const hours = ("0" + d.getHours()).slice(-2);
const minutes = ("0" + d.getMinutes()).slice(-2);
const seconds = ("0" + d.getSeconds()).slice(-2);
// join times
const quizTime = hours + ":" + minutes + ":" + seconds;
this.quizService.quizCreate(
sems.quiz_time = quizTime, // send joined time (00:00:27)
).subscribe(
(data: any) => {
console.log(data.message);
},
error => {
//
},
() => {
//
}
);
}
希望它可以帮助别人。
添加回答
举报