change time format to 24 hours in javascript

前端 未结 7 953
春和景丽
春和景丽 2020-12-15 23:12

I have a time format like: 12/16/2011 3:49:37 PM and I got this format by:

var newDate = new Date(timeFromat);
timeFormat = newDate.toLocaleString();
         


        
7条回答
  •  青春惊慌失措
    2020-12-15 23:37

    You can use the below code to get 24hrs format

    new Date("3/16/2011 3:49:37 PM").getHours() // 15
    new Date("3/16/2011 3:49:37 PM").getMinutes() // 49
    

提交回复
热议问题