Javascript Date.parse help

前端 未结 3 1778
孤独总比滥情好
孤独总比滥情好 2021-01-19 23:42

I am using Javascript Date.parse() to check if a start time is after an end time.

The time in question is like this:

Date.parse("12:0         


        
3条回答
  •  半阙折子戏
    2021-01-20 00:21

    The docs for Date.parse() in IE state the following:

    If the 24-hour clock is used, it is an error to specify "PM" for times later than 12 noon. For example, "23:15 PM" is an error.

    For a cross-browser solution, you should avoid parse() and parse the time string manually. Alternatively, you could use a cross-browser library for parsing dates/times - DateJS is a popular one.

提交回复
热议问题