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

前端 未结 11 989
小蘑菇
小蘑菇 2020-12-07 15:56

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 s

11条回答
  •  难免孤独
    2020-12-07 16:41

    This works for me:

    var date = new Date();
    var string = date.toLocaleTimeString([], {timeStyle: 'short'});
    
    

提交回复
热议问题