I am using https://valor-software.com/ngx-bootstrap/#/timepicker in my angular project.
I have one task o covert that time to UTC before I request to server.
When I select Time from timepicker value coming is as below.
Now, I have created one function to convert it to UTC using moment.js
static FormatimeSpanBeforeSubmit(date: Date | string ) {
const dateFromTimePicker = date as Date;
// Convert it to format "HH:mm:ss"
let formatedTime = moment.utc(dateFromTimePicker).format('HH:mm:ss');
// Split details in array because I want seconds as always "00"
let list = formatedTime.split(/[\s:]+/);
// Updating last value ""ss" to "00"
formatedTime = formatedTime.replace(new RegExp(list[list.length -1] + '$'), '00');
//Final value
return date ? formatedTime : null;
}
Expected Output : It should convert my time as "9:51:00"
Current Output : "10:54:00"
Please help me and guide me how can I get correct value.
Comment :
(2) As per comments from Hoài Nam I have updated my code like below and in that I am still getting 10:54:00