How to get current time in a format hh:mm AM/PM in Javascript?

后端 未结 4 1349
小鲜肉
小鲜肉 2021-01-05 11:26

I have a Javascript in which I need to paste the current time in a format HH:MM AM/PM. There\'s one catch - I need to put the time that starts in two hours from now, so for

4条回答
  •  走了就别回头了
    2021-01-05 12:24

    Note that the accepted answer, while good, does not appear to meet the format requirement of: HH:MM AM/PM. It returns midnight as "0:0:38am" and so forth.

    There are many ways one could do this and one alternative is shown below. Click the "Run Code Snippet" to test.

    
    
    
    
    Clock
    
    
    00:00:00 AM
    
    
    

提交回复
热议问题