I have this datetime string
"2017-05-12T22:35:58.873912"
I want it to be
"22:35:58"
So the expected format should be HH:mm:ss , how can I do that? Thanks in advance.
I have this datetime string
"2017-05-12T22:35:58.873912"
I want it to be
"22:35:58"
So the expected format should be HH:mm:ss , how can I do that? Thanks in advance.
Firstly, create a variable that stores this.
var currentTime = new Date();
Then, you're going to want to use the .getHours, .getMinutes and .getSeconds methods to get each one of those, then display them in a string.
console.log("The current time is " +
currentTime.getHours() + ":" +
currentTime.getMinutes() + ":" +
currentTime.getSeconds()
);
Please note that this will display the time in military time, in case you are someone outside of that time specification.