I have this string 2022-02-25 06:09 AM
. How do I use return just 06:09 AM
(without seconds)?
I tried two ways. One way is to convert the string into Date object and then use toLocaleTimeString
. But the output is 6:09:00 AM
which includes the second. Here is my code.
getMyTime(lastUpdate) {
let d = new Date(lastUpdate);
return d.toLocaleTimeString();
},
The other way is I used substring which returns 25 06:09 AM
. Not sure why it get 25
. Here is my code.
getMyTime(lastUpdate) {
return lastUpdate.substring(19,8);
},