I really love Javascript and I wrote my code like this. I feel like it should work. Am I doing it in the wrong order? If it won't work like this why not?
var mydate = new Date();
alert( mydate.toLocaleTimeString().split(":").pop().join(':'));
split() makes it an array, pop() takes off the end of the array, join() makes it a string again right?
You could use Array#slice with a negative end/second argument.
Array#pop returns the last element, but not the array itself. slice returns a copy of the array with all emements from start without the last element.
var mydate = new Date();
console.log(mydate.toLocaleTimeString().split(":").slice(0, -1).join(':'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With