Reputation: 127
I have this:
var myDate = new Date(r.date).toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1");
which returns the format in hh:MM:ss
However I only want the hh:MM formatwithout the seconds.
Any suggestions?
Upvotes: 1
Views: 852
Reputation: 27119
Just take the last part of the regexp (the one that includes the seconds) out of the group, like this
var myDate = new Date(r.date).toTimeString().replace(/.*(\d{2}:\d{2}):\d{2}.*/, "$1");
so that the substitution only takes the first two numbers, a colon and another couple of numbers into account.
Upvotes: 1