Convert string to Time

前端 未结 4 604
忘了有多久
忘了有多久 2021-02-01 13:23

I have a time that is 16:23:01. I tried using DateTime.ParseExact, but it\'s not working.

Here is my code:

string Time = \"16:23:01\"; 
Date         


        
4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-01 14:05

    The accepted solution doesn't cover edge cases. I found the way to do this with 4KB script. Handle your input and convert a data.

    Examples:

    00:00:00 -> 00:00:00
    12:01 -> 12:01:00
    12 -> 12:00:00
    25 -> 00:00:00
    12:60:60 -> 12:00:00
    1dg46 -> 14:06
    

    You got the idea... Check it https://github.com/alekspetrov/time-input-js

提交回复
热议问题