How do I use .toLocaleTimeString() without displaying seconds?

I’m currently attempting to display the user’s time without displaying the seconds. Is there a way I can do this using Javascript’s .toLocaleTimeString()?

Doing something like this:

var date = new Date();
var string = date.toLocaleTimeString();

will display the user’s time with every unit, e.g. currently it displays 3:39:15 PM. Am I able to display that same string, just without the seconds? (e.g. 3:39 PM)

12 Answers
12

Leave a Comment