How to show only hours and minutes from javascript date.toLocaleTimeString()?

前端 未结 5 1200
無奈伤痛
無奈伤痛 2020-12-16 11:02

Can anyone please help me get the HH:MM am/pm format instead of HH:MM:SS am/pm.

My javascript code is :



        
5条回答
  •  猫巷女王i
    2020-12-16 11:49

    I posted my solution here https://stackoverflow.com/a/48595422/6204133

    var textTime = new Date(sunriseMills + offsetCityMills + offsetDeviceMills) 
                    .toLocaleTimeString('en-US', { hour: 'numeric', minute: 'numeric' });
    

提交回复
热议问题