How to convert time to 24 hours format in javascript | letsbug
Today is we are doing something which is the most basic thing that you come across in your everyday life. But barely notice it. And while you are learning programming you may have sometimes ignored it. It is time converting or changing it to different format. And we will see How To Convert Time To 24 Hours Military Format In Javascript So, lets get started by creating a function. Name the function anything you want mine is timeConverter(time). We are passing time to the function. Time which we are passing is a string like this "1:00:05AM". Now in the function first lets extract some important data from the input. Like we will extract hours, minutes and seconds. Then as the format of input time is in 12 hours that means we will have AM/PM to differentiate between day and night. So, we will extract that data also. The variable half stores AM or PM. After we have all the data extrac...